Advertisement
wofus

Push Nachricht

Oct 31st, 2023
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5.  
  6. require_once('token.php');
  7.  
  8.     $fcmEndpoint = "https://fcm.googleapis.com/v1/projects/?/messages:send";
  9.  
  10.     $headers = [
  11.         'Authorization: Bearer ' . $jwtToken,
  12.         'Content-Type: application/json',
  13.     ];
  14.  
  15.     $data = [
  16.         'message' => [
  17.             'token' => '?',
  18.             'notification' => [
  19.                 'title' => 'Titel der Benachrichtigung',
  20.                 'body' => 'Inhalt der Benachrichtigung',
  21.             ],
  22.         ],
  23.     ];
  24.  
  25.     $ch = curl_init($fcmEndpoint);
  26.     curl_setopt($ch, CURLOPT_POST, true);
  27.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  28.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  29.     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  30.  
  31.     $response = curl_exec($ch);
  32.     curl_close($ch);
  33.  
  34.     echo $response;
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement