Guest User

Untitled

a guest
Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public function send_FCM(){
  2. // Method - 1
  3. $fcmUrl = 'https://fcm.googleapis.com/v1/projects/anal.........719/messages:send';
  4. $notification = array(
  5. "to"=>"/topic/cidade396",
  6. "notification"=>array(
  7. "body"=>"test 123"
  8. )
  9. );
  10. $headers = [
  11. 'Authorization: key=AIz.........9KWwy5BisxXYbA8',
  12. 'Content-Type: application/json'
  13. ];
  14. $ch = curl_init();
  15. curl_setopt($ch, CURLOPT_URL,$fcmUrl);
  16. curl_setopt($ch, CURLOPT_POST, true);
  17. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  18. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  19. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($notification));
  21. $result = curl_exec($ch);
  22. curl_close($ch);
  23. var_dump($result);
  24. return true;
Add Comment
Please, Sign In to add comment