Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cURL to PHP:解析服务器推送通知_Php_Curl_Heroku_Parse Platform_Parse Server - Fatal编程技术网

cURL to PHP:解析服务器推送通知

cURL to PHP:解析服务器推送通知,php,curl,heroku,parse-platform,parse-server,Php,Curl,Heroku,Parse Platform,Parse Server,我想向所有用户推送带有cURL的通知 这是我的.php: <?php $url = 'https://myApp.herokuapp.com/parse/push'; $data = array( 'channels' => '', 'type' => 'ios', 'data' => array( 'title' => 'test', 'alert' => 'greetings programs',

我想向所有用户推送带有cURL的通知

这是我的.php:

<?php
$url = 'https://myApp.herokuapp.com/parse/push';
$data = array(
    'channels' => '',
    'type' => 'ios',
    'data' => array(
        'title' => 'test',
        'alert' => 'greetings programs',
    ),
);
$_data = json_encode($data);
$headers = array(
    'X-Parse-Application-Id:xx',
    'X-Parse-Master-Key:xx',
    'X-Parse-REST-API-Key:xx',
    '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);
?>
但我的应用程序上没有通知。 我如何用我的代码解决这个问题

当我在数据库中查找时,如果:

{
    "_id": {
        "$oid": "570ea4695b1cec1100583fb4"
    },
    "objectId": "Kt6PI0vRHI",
    "pushTime": "2016-04-13T19:56:25.251Z",
    "_created_at": {
        "$date": "2016-04-13T19:56:25.251Z"
    },
    "query": "{\"channels\":{\"$in\":\"\"}}",
    "payload": {
        "title": "test",
        "alert": "greetings programs"
    },
    "source": "rest",
    "title": null,
    "expiry": null,
    "status": "failed",
    "numSent": 0,
    "pushHash": "e08f4b8382fdee50fb6547236c7ea2a3",
    "_wperm": [],
    "_rperm": [],
    "errorMessage": "{\"code\":107,\"message\":\"bad $in value\"}"
}

我宁愿创建一个用于发送推送通知的云函数,并使用php调用该函数,因为这样您就不必通过网络传输masterkey…@MazelTov感谢您的回复!我怎样才能做到?
{
    "_id": {
        "$oid": "570ea4695b1cec1100583fb4"
    },
    "objectId": "Kt6PI0vRHI",
    "pushTime": "2016-04-13T19:56:25.251Z",
    "_created_at": {
        "$date": "2016-04-13T19:56:25.251Z"
    },
    "query": "{\"channels\":{\"$in\":\"\"}}",
    "payload": {
        "title": "test",
        "alert": "greetings programs"
    },
    "source": "rest",
    "title": null,
    "expiry": null,
    "status": "failed",
    "numSent": 0,
    "pushHash": "e08f4b8382fdee50fb6547236c7ea2a3",
    "_wperm": [],
    "_rperm": [],
    "errorMessage": "{\"code\":107,\"message\":\"bad $in value\"}"
}