Add SPOTA core PHP application
Add the main admin, dosen, mahasiswa, API, and service code needed to run the core legacy application with configurable upload storage.
This commit is contained in:
37
inc/gcm_helper.php
Normal file
37
inc/gcm_helper.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//GCM Function- Ridwan Tasa Dirsa (D03109031)
|
||||
//for SPota Android
|
||||
function sendPushNotificationToGCM($registation_ids, $message) {
|
||||
return;
|
||||
//Google cloud messaging GCM-API url
|
||||
$url = 'https://android.googleapis.com/gcm/send';
|
||||
$fields = array(
|
||||
'registration_ids' => $registation_ids,
|
||||
'data' => $message,
|
||||
);
|
||||
// Update your Google Cloud Messaging API Key
|
||||
//GOOGLE_API_KEY defined at konfigurasi.php
|
||||
$headers = array(
|
||||
'Authorization: key=' . GOOGLE_API_KEY,
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
|
||||
$result = curl_exec($ch);
|
||||
if ($result === FALSE) {
|
||||
die('Curl failed: ' . curl_error($ch));
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
?>
|
||||
Reference in New Issue
Block a user