错误107无效的JSON解析rest API -应用程序打开


Error 107 Invalid JSON Parse Rested API - App Opens

我正在尝试与Parse rest API一起构建一个自定义分析面板。

当请求打开应用程序时,我总是得到错误

{"code":107,"error":"invalid JSON"}

当尝试请求打开应用程序时。

我是这样执行cURL请求的:

$service_url = 'https://api.parse.com/1/events/AppOpened';
$appId = 'abc';
$restKey = 'efg';
$header = array( 
    "Content-Type: application/json",  
    "X-Parse-Application-Id: " . $appId,  
    "X-Parse-REST-API-Key: " . $restKey
);  

 $rest = curl_init();  
 curl_setopt($rest,CURLOPT_URL,$service_url);  
 curl_setopt($rest,CURLOPT_POST,1);  
 curl_setopt($rest,CURLOPT_HTTPHEADER,$header);  
 curl_setopt($rest,CURLOPT_SSL_VERIFYPEER, false);  
 curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);  
 $response = curl_exec($rest);  
 echo $response;  
 print_r($response);  
 curl_close($rest); 

当发送一个空JSON对象时,Parse不再出错,而是返回一个空JSON对象。

这是您的方法App-Open Analytics的文档,据我所知,至少期望您的空JSON对象

从他们的cUrl示例中可以明显看出

-d '{
    }' '

在PHP中也可以使用

curl_setopt($rest, CURLOPT_POSTFIELDS, '{}');