Created
August 25, 2015 18:49
-
-
Save sunnyluthra/760a8588464dfb5afd91 to your computer and use it in GitHub Desktop.
Revisions
-
sunnyluthra created this gist
Aug 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ function verify_notification_token($token) { $fields = array( 'dry_run' => true, 'to' => $token, ); $headers = array( 'Authorization: key=' . GOOGLE_API_SERVER_KEY, 'Content-Type: application/json', ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, GOOGLE_API_PUSH_URL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); curl_close($ch); $result = json_decode($result); //Success //([multicast_id] => -1 // [success] => 1 // [failure] => 0 // [canonical_ids] => 0 // [results] => Array // ( // [0] => stdClass Object // ( // [message_id] => fake_message_id // ) // ) // ) if($result->success === 1){ return true; }else{ return false; } }