Langsung saja buat file php dan isi script seperti dibawah ini.
<?php $url = 'https://gcm-http.googleapis.com/gcm/send'; $fields = ' { "data": { "pesan": pesan anda, }, "to": "/topics/global" }'; $headers = array( 'Authorization: key=key_GCM_anda', 'Content-Type: application/json' ); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Disabling SSL Certificate support temporarly curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // Execute post $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } // Close connection curl_close($ch); print_r($result); ?>
Tinggal jalankan aja di web server anda.
Post a Comment