I need my PHP system to send a Push notification to certain user identified by a userID.
I tried this code and it just won't work:
$APPLICATION_ID = "XXXXXX";
$REST_API_KEY = "XXXXXXX";
$MESSAGE = "your-alert-message";
$url = 'https://api.parse.com/1/push';
$data = array(
'type' => 'android',
'where' => array(
'userID' => 102102
),
'data' => array(
'alert' => 'greetings programs',
),
);
echo $_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);
echo curl_exec($curl);
Where am I wrong?