Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Vladimir Zhelnov - neatek.pw - Web/iOS dev
- // PushServer for Radiovera.ru
- // Your Message
- $data = [
- "to" => "/topics/push", // here is Topic (create in AndroidApp, or device token)
- // customizated notification message on override onMessageReceived Android App
- "data" => [
- "message" => "Привет мир",
- "title" => "РАДИО ВЕРА"
- ],
- // here is default notification without customization
- /* "notification" => [
- "body" => "Привет мир",
- "title" => "РАДИО ВЕРА",
- "icon" => "myicon",
- "sound" => "default"
- ]*/
- ];
- // Process send that notification to users
- $data_string = json_encode( $data );
- $ch = curl_init('https://fcm.googleapis.com/fcm/send');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER,
- [
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($data_string),
- 'Authorization: key=HERE_IS_TOKEN_OF_FIREBASE_MESSAGING'
- ]
- );
- $result = curl_exec($ch);
- var_dump($result);
Add Comment
Please, Sign In to add comment