Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $url = "https://fcm.googleapis.com/fcm/send";
- $headers = array(
- "Authorization : key=AAAAVowCLac:APA91bGdY5WrVjAbVfKpqoRmehjfV2wu8Zkd_rQI3kSbTtVELkWDX8kEsGbKnOpRMrF26kD8kHpwdJ781JdkWKL2_KqGt5hFdHYmfS_TJB0fc2YqW0bQy8CVPCTdPS8DqpJEpLlwUifv",
- "Content-Type : application/json",
- );
- $post_data = array(
- 'to' => "/topics/all",
- 'notification' => array(
- 'sound' => "default"
- ),
- 'data' => [
- 'stage' => "LOC" // LOC => LOCAL, DEV => DEVELOPMENT, TES => TEST, REL => RELEASE
- 'show' => "1" // 0 => tidak ditampilkan, 1 => ditampilkan
- 'title' => "judul",
- 'body' => "isi",
- 'id_skk' => "LOG001".
- 'refresh' => ["1", "2"] // 0 => TIDAK ADA REFRESH, 1 => REFRESH PENGAJUAN, 2 => REFRESH LAPORAN, 3 => REFRESH MUTASI
- ],
- 'priority' => "high" // HIGH, NORMAL
- );
- $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_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
- $result = curl_exec($ch);
- curl_close($ch);
- return json_decode($result, true)['message_id'] ?? "tidak terkirim";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement