Guest User

Untitled

a guest
Mar 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. $msg = array
  2. (
  3. 'body' => 'Test Test',
  4. 'title' => 'Test',
  5. 'click_action' => 'https://google.com/',
  6. 'icon' => 'smallicon',/*Default Icon*/
  7. 'sound' => 'mySound'/*Default sound*/
  8. );
  9. $fields = array
  10. (
  11. 'to' => 'token',
  12. 'notification' => $msg
  13. );
  14.  
  15.  
  16. $headers = array
  17. (
  18. 'Authorization: key=',
  19. 'Content-Type: application/json'
  20. );
  21. $ch = curl_init();
  22. curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
  23. curl_setopt( $ch,CURLOPT_POST, true );
  24. curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
  25. curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
  26. curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
  27. curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
  28. $result = curl_exec($ch );
  29. curl_close( $ch );
Add Comment
Please, Sign In to add comment