| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- // Send notifications One device
- // Hämta token från sql användaren
- $token = "eMvkzPwkTheSeFLFAE5fho:APA91bE-pb5_0xoMn_Bza6-HrgpI5ufKPZ7zhF4NM_leYdfgYTk4MZJdfpfiKDkijUuQAiK7iaT7rXJucF20uh1GvmgjiomiuQehnDHcjUkGjaSvkQtVfj_s0AtLSPjIJz8EQ5Aujkfk";
- $message = "TEST MEDDELANDE FRÅN SERVERN";
- $title = "TEST TITEL";
- $url = "https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send";
- $fields = array(
- "message" => array(
- "token" => $token,
- "notification" =>
- array(
- "body" => $message,
- "title" => $title
- )
- )
- );
- $fields = json_encode($fields);
- $headers = array(
- 'Content-Type: application/json',
- 'Authorization: Bearer ' . "AAAAGStp88I:APA91bERuLuU7DuAyW2yhoLQeiJizGZVsezzEdLhRa9v9Ehy7uYmHFvBTMrQooMDg0oaGNZE3DXd3Tl3E10JP58OCtuL7z1UQWo071tOCR8Ede3YUXDErs6Zkt8z1VxcBAkOxzVInId3"
- );
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
- $response = curl_exec($curl);
- var_dump($response);
- curl_close($curl);
- /*
- curl -X POST -H "Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA" -H "Content-Type: application/json" -d '{
- "message":{
- "notification":{
- "title":"FCM Message",
- "body":"This is an FCM Message"
- },
- "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
- }}' https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send
- */
|