Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public function curl()
  2. {
  3. $api_key = "AIzaSyAS6TCYSTEJhLZ0gkFEvK9fbVylVxvlJqs";
  4. $registrationIDs = "AAAAbRNUN9o:APA91bF7GjvxW2PuOoxG_PKGho7lJ2gkfISdGm4m5sJwKuM1tCTqH0PrcgNPGB1SgpjIlM7_mgNy-hNJtSbYBop9ShNdRqZHqpIEAA4noLS6enz_5zBpXeaV6peRXSzb5iUjON4ypIlD";
  5. $data = array(
  6. "to" => array($registrationIDs),
  7. "notification" => array("title" => "Shareurcodes.com", "body" => "A Code Sharing Blog!", "icon" => "icon.png", "click_action" => "http://shareurcodes.com")
  8. );
  9. $data_string = json_encode($data);
  10.  
  11. echo "The Json Data : " . $data_string;
  12.  
  13. $headers = array(
  14. 'Authorization: key=' . $api_key,
  15. 'Content-Type: application/json'
  16. );
  17.  
  18. $ch = curl_init();
  19.  
  20. curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
  21. curl_setopt($ch, CURLOPT_POST, true);
  22. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  24. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  25.  
  26. $result = curl_exec($ch);
  27.  
  28. curl_close($ch);
  29.  
  30. dd($result);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement