我正在使用phonegap创建一个应用。我想使用解析推送通知。我正在尝试使用PHP在解析时安装我的应用程序。我在this tutorial看到了安装过程。 之后我尝试了以下: -
$APPLICATION_ID = "8duVhrDRACPwXr8lY0dfsdsdfsdvUH";
$REST_API_KEY = "oIMqyqweSELdgiosdfsdwerWq8IxJ7Kv";
$url = 'https://api.parse.com/1/installations';
$data = array(
'deviceType' => 'android',
'deviceToken' => 'APA91bEnL9hUgExuwrmFchzfpmHG79zfmdIDLP5nZfsdfstdimbGQFMlIOR2PyGcXdFAaM3S6U2rzMEt8Hl3UdiagonwMCMQ209_rrDqVp91jVtLFtfcrBLQNCM4HloMrzlkv5gGp0sLP7Ie9sdfYiaxdO3QHdp64',
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
$response=curl_exec($curl);
var_dump($response);
我不确定为什么它会返回false。我检查了app id,rest api id和device token。我的代码中是否有任何错误。
答案 0 :(得分:0)
您没有执行 cURL
这样做
$response = curl_exec($curl); // <-- Add this before your var_dump.
var_dump($response);