Created
August 4, 2014 12:23
-
-
Save yudanta/6ecd7ac0388d8ea77769 to your computer and use it in GitHub Desktop.
sample post to gcm
This file contains 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 characters
<?php | |
$apiKey = "api_key"; | |
$messageData = array( | |
"code" => 1001, | |
"subject" => "hai kak zam", | |
"messages" => "hai kak zam", | |
); | |
$registrationIdsArray = array("gcm_id"); | |
$headers = array("Content-Type:" . "application/json", "Authorization:" . "key=" . $apiKey); | |
$data = array( | |
'data' => $messageData, | |
'registration_ids' => $registrationIdsArray | |
); | |
$ch = curl_init(); | |
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); | |
curl_setopt( $ch, CURLOPT_URL, "https://android.googleapis.com/gcm/send" ); | |
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); | |
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); | |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); | |
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($data) ); | |
$response = curl_exec($ch); | |
print_r($response); | |
curl_close($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment