Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function send_FCM(){
- // Method - 1
- $fcmUrl = 'https://fcm.googleapis.com/v1/projects/anal.........719/messages:send';
- $notification = array(
- "to"=>"/topic/cidade396",
- "notification"=>array(
- "body"=>"test 123"
- )
- );
- $headers = [
- 'Authorization: key=AIz.........9KWwy5BisxXYbA8',
- 'Content-Type: application/json'
- ];
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$fcmUrl);
- 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($notification));
- $result = curl_exec($ch);
- curl_close($ch);
- var_dump($result);
- return true;
Add Comment
Please, Sign In to add comment