Skip to content

Instantly share code, notes, and snippets.

@VictorAlbertos
Created September 10, 2015 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VictorAlbertos/a08ec8cf34846b304140 to your computer and use it in GitHub Desktop.
Save VictorAlbertos/a08ec8cf34846b304140 to your computer and use it in GitHub Desktop.
public function send($userId, $message, $email) {
$data = array(
'where' => array('userId' => $userId, 'email' => $email),
'data' => array(
"alert" => $message,
"sound" => "default",
"badge" => "Increment"
)
);
$_data = json_encode($data);
$ch = curl_init();
$query = urlencode('where={"userId":"'.$userId.'", "email":"'.$email.'"}');
$url = self::PARSER_URL_PUSH . "?" . $query;
curl_setopt($ch, CURLOPT_URL, $url);
$headers = array();
$headers[] = 'X-Parse-Application-Id: '. self::APP_ID;
$headers[] = 'X-Parse-Master-Key: '. self::MASTER_KEY;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close ($ch);
$results = json_decode($server_output, true);
$results = $results['results'][0];
return json_encode($results);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment