<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'XXXXXXXXXXXXXXXXXX' );
$registrationIds = array( TOKENS );
// prep the bundle
$msg = array
(
'body' => 'mensagem via api',
'title' => 'Hello from Api'
//'vibrate' => 1,
//'sound' => 1,
);
$fields = array
(
'to' => '/topics/general',
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json;charset=UTF-8'
);
$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, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>