Skip to content

Instantly share code, notes, and snippets.

@layerlre
Created January 13, 2016 15:26
Show Gist options
  • Save layerlre/15873c399db4456e989f to your computer and use it in GitHub Desktop.
Save layerlre/15873c399db4456e989f to your computer and use it in GitHub Desktop.
Parse Push Notification Api example
public function sendNotification($MESSAGE)
{
$APPLICATION_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$REST_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$url = 'https://api.parse.com/1/push';
$data = array(
'expiry' => 1451606400,
'data' => array(
'alert' => $MESSAGE,
),
'is_background' => false,
'where' => array(
'deviceType' => 'android',
)
);
$_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_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment