<?php
$APPLICATION_ID = "XXXXXXXXXXXXXXX";
$REST_API_KEY = "XXXXXXXXXXXXXX";
$url = 'https://api.parse.com/1/push';
$data = array(
'channel' => 'News',
'type' => 'ios',
'expiry' => 1451606400,
'data' => array(
'alert' => 'Test Push',
'sound' => 'push.caf',
),
);
$_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($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
?>
我正在使用此脚本发送推送通知。提到频道是强制性的吗?
每当我运行此脚本时,我都没有收到任何通知,而当我从解析站点发送时,设备正在接收通知。请帮忙。
答案 0 :(得分:0)
你可以使用slim库....查看此链接 http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
答案 1 :(得分:0)
你必须使用where子句
$data = array(
//'channel' => 'News',
//'type' => 'ios',
'where'=>'{}'
'expiry' => 1451606400,
'data' => array(
'alert' => 'Test Push',
'sound' => 'push.caf',
),);