我需要将推送消息从web服务发送到windowsphone。我可以从控制台实现这一点,但我需要使用php脚本来实现
我尝试过的代码:
$url = 'https://api.parse.com/1/push';
$appId = 'xxx';
$restKey = 'xxx';
$push_payload = json_encode(array(
"where" => '"deviceType"=>"winrt"',
"data" => array(
"alert" => "This is the alert text."
)
));
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_PORT,443);
curl_setopt($rest,CURLOPT_POST,1);
curl_setopt($rest,CURLOPT_POSTFIELDS,$push_payload);
curl_setopt($rest,CURLOPT_HTTPHEADER,
array("X-Parse-Application-Id: " . $appId,
"X-Parse-REST-API-Key: " . $restKey,
"Content-Type: application/json"));
$response = curl_exec($rest);
echo $response;
var_dump($response);
}
但在转储响应时,我得到了一个布尔值:false,并且手机上没有显示任何通知。
试试这个:
$push_payload = json_encode(array(
"where" => array("deviceType" => "winrt"),
"data" => array("alert" => "This is the alert text.")
));