Created
August 18, 2014 15:19
-
-
Save yudanta/fe08735a509a6e6eb089 to your computer and use it in GitHub Desktop.
GCM php
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 | |
$url = "https://android.googleapis.com/gcm/send"; | |
$api_key = "<api key>"; | |
$client_id = array("gcm_id"); | |
$headers = array( | |
"Content-type: application/json", | |
"Authorization: key=" . $api_key, | |
); | |
$data = array( | |
'msgid' => 2020, | |
'ncode' => 1001, | |
'sender' => 'Ydn', | |
'send_date' => '2014-08-10 10:11:12', | |
'subject' => 'test pake php', | |
'messages' => 'haee yudan', | |
'extras' => array("idJob"=>1, "idTicket"=>10, "ticket_no"=>"BCA_IN_AAAB"), | |
); | |
$postdata = array( | |
'data' => $data, | |
'registration_ids' => $client_id, | |
); | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_RETURNTRANSFER => 1, | |
CURLOPT_URL => $url, | |
CURLOPT_HTTPHEADER => $headers, | |
CURLOPT_POST => 1, | |
CURLOPT_POSTFIELDS => json_encode($postdata) | |
)); | |
$resp = curl_exec($curl); | |
curl_close($curl); | |
var_dump($resp); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment