从php发送推送通知

从php发送推送通知,php,push-notification,Php,Push Notification,我正在使用此脚本发送推送通知。必须提到频道吗 无论何时运行此脚本,我都不会收到任何通知,而当我从解析站点发送时,设备会收到通知。请提供帮助。您可以使用slim library进行此操作……请检查此链接 您必须使用where子句 <?php $APPLICATION_ID = "XXXXXXXXXXXXXXX"; $REST_API_KEY = "XXXXXXXXXXXXXX"; $url = 'https://api.parse.com/1/push'; $data = array(

我正在使用此脚本发送推送通知。必须提到频道吗


无论何时运行此脚本,我都不会收到任何通知,而当我从解析站点发送时,设备会收到通知。请提供帮助。

您可以使用slim library进行此操作……请检查此链接
您必须使用where子句

<?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);

?>

这应该发送给你通知名单上的每个人吗?我看不出收件人是在哪里定义的。在服务器上运行此脚本时是否启用了错误显示/是否看到任何错误?您是否看到来自parse的成功消息?需要更多的信息来帮助。您尝试过什么?请解释您的答案是如何解决问题的,它将帮助每个人更清楚地理解您的解决方案,以供将来参考。where子句将向在安装对象上注册的所有设备发送消息。在这种情况下,不得与任何特定值进行比较。这对我有用。
$data = array(
  //'channel' => 'News',
  //'type' => 'ios',
  'where'=>'{}'
'expiry' => 1451606400,
'data' => array(
    'alert' => 'Test Push',
    'sound' => 'push.caf',
),);