Php 谷歌API获取购买inap的状态为“返回”;“未找到”;

Php 谷歌API获取购买inap的状态为“返回”;“未找到”;,php,android,in-app-billing,Php,Android,In App Billing,我参考google play android api来检查应用内项目的购买和消费状态。但返回如下错误: C:\ProgramFiles\VertrigoServ\www\inapp\index.php:74:null 未找到 我不明白他为什么不给我返回一个无效的json,它只给我返回一个文本,上面写着“找不到” 我使用函数来getToken(),她工作得很好。。。但是功能 getStatusInapp($pProductIdStr$lAccessToken)不起作用 我做错了什么 functio

我参考google play android api来检查应用内项目的购买和消费状态。但返回如下错误:

C:\ProgramFiles\VertrigoServ\www\inapp\index.php:74:null
未找到

我不明白他为什么不给我返回一个无效的json,它只给我返回一个文本,上面写着“找不到”

我使用函数来
getToken()
,她工作得很好。。。但是功能
getStatusInapp($pProductIdStr$lAccessToken)
不起作用

我做错了什么

function getToken(){

GLOBAL $lPackageNameStr; // Name of package Name (com.example.app)
GLOBAL $client_id; // my client id from google
GLOBAL $client_secret; // my client secret from google
GLOBAL $refresh_token; // the refresh token
GLOBAL $pReceiptStr; // token of inap purchase

$url ="https://accounts.google.com/o/oauth2/token";
$fields = array(
   "client_id"=>$client_id,
   "client_secret"=>$client_secret,
   "refresh_token"=>$refresh_token,
   "grant_type"=>"refresh_token");

$ch = curl_init($url);
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_POST,count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute post
$lResponse_json = (curl_exec($ch));
$lAccessToken = json_decode($lResponse_json)->{'access_token'};
//close connection
curl_close($ch);
return $lAccessToken;
}

function getStatusInapp($pProductIdStr, $lAccessToken){

GLOBAL $lPackageNameStr; // Name of package Name (com.example.app)
GLOBAL $client_id; // my client id from google
GLOBAL $client_secret; // my client secret from google
GLOBAL $refresh_token; // the refresh token
GLOBAL $pReceiptStr; // token of inaap purchase

/*
# What is the correct way to sku?

$pProductIdStr = "teste_01";
------------ or --------------
$pProductIdStr = "com.example.app.teste_01";
------------ or --------------
$pProductIdStr = "inap:com.example.app:teste_01";

# On Google Play Developer Console the sku is:> teste_01


*/

$lURLStr =  ("https://www.googleapis.com/androidpublisher/v2/applications/$lPackageNameStr/purchases/$pProductIdStr/purchases/$pReceiptStr");

$curl = curl_init($lURLStr);

curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
$curlheader[0] = "Authorization: Bearer " . $lAccessToken;
curl_setopt($curl, CURLOPT_HTTPHEADER, $curlheader);

$json_response = curl_exec($curl);
curl_close($curl);

//echo $json_response;
$responseObj = json_decode($json_response,true);
var_dump($responseObj);
echo $json_response;
}

/*
| Execute...
*/

getStatusInapp($pProductIdStr, getToken());

看起来您的API端点路径有误。文档将url描述为:

packageName/purchases/products/productId/tokens/token

将您的
$lURLStr
更改为:

"https://www.googleapis.com/androidpublisher/v2/applications/$lPackageNameStr/purchases/products/$pProductIdStr/tokens/$pReceiptStr"

看起来您的API端点路径有误。文档将url描述为:

packageName/purchases/products/productId/tokens/token

将您的
$lURLStr
更改为:

"https://www.googleapis.com/androidpublisher/v2/applications/$lPackageNameStr/purchases/products/$pProductIdStr/tokens/$pReceiptStr"

真的谢谢!!而productId be是
$pProductIdStr=“teste_01”------------或-----------------$pProductIdStr=“com.example.app.teste\u 01”------------或者-----------------$pProductIdStr=“inap:com.example.app:teste_01”productId应该与Google Play开发者控制台中显示的完全相同。“名称/标识”列括号内的应用内产品列表中显示的内容是您需要设置为$pProductIdStr的内容。真的谢谢!!而productId be是
$pProductIdStr=“teste_01”------------或-----------------$pProductIdStr=“com.example.app.teste\u 01”------------或者-----------------$pProductIdStr=“inap:com.example.app:teste_01”productId应该与Google Play开发者控制台中显示的完全相同。“名称/标识”列括号内的应用内产品列表中显示的内容是您需要设置为$pProductIdStr的内容。