Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
    
By the way, the userID is correctly set in the installation and I can send the notification from the webpage in parse.com –  Allfarid Morales García Jul 8 '14 at 5:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.