| 12345678910111213141516171819202122232425262728 |
- <?php
- require_once '../vendor/autoload.php';
- putenv('GOOGLE_APPLICATION_CREDENTIALS=/home/axel/configs/narkampen-firebase-adminsdk-k42j5-d3d0354e37.json');
- $client = new Google_Client();
- $client->useApplicationDefaultCredentials();
- $client->addScope('https://www.googleapis.com/auth/firebase.messaging');
- $httpClient = $client->authorize();
- $token = "f2lMMUNKR9SOQcVZFm7VUJ:APA91bHnfv3D2yxAPX9lXT81ovuH6gDgga6ZrNXRwAZZE5xa7AcjWzeKAON-7s1oAVM4AwTSgjb-IkmT5NvujjqSib9wFCcwaPX205dh8rSGAj6ltTp670dTkdbVIykefURMoG8EhFQd";
- // Your Firebase project ID
- $project = "narkampen";
- // Creates a notification for subscribers to the debug topic
- $message = [
- "message" => [
- "token" => $token,
- "notification" => [
- "body" => "This is an FCM notification message!",
- "title" => "FCM Message",
- ]
- ]
- ];
- // Send the Push Notification - use $response to inspect success or errors
- $response = $httpClient->post("https://fcm.googleapis.com/v1/projects/{$project}/messages:send", ['json' => $message]);
- var_dump($response);
|