Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // API access key from Google API's Console
- define( 'API_ACCESS_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' );
- // set only for one for safety
- $registrationId = $_GET['id'];
- $texto = $_GET['texto'];
- // prep the bundle
- $msg = array
- (
- 'title' => 'Notificação',
- 'body' => $texto,
- 'icon' => 'myicon',
- 'sound' => 'default'
- );
- $fields = array
- (
- 'priority' => 'high',
- 'to' => $registrationId,
- 'notification' => $msg
- );
- $headers = array
- (
- 'Authorization: key=' . API_ACCESS_KEY,
- 'Content-Type: application/json'
- );
- $ch = curl_init();
- curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
- curl_setopt( $ch,CURLOPT_POST, true );
- curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
- curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
- curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
- curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
- $result = curl_exec($ch );
- curl_close( $ch );
- echo $result;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement