PHP code example of kerox / fcm
1. Go to this page and download the library: Download kerox/fcm library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kerox / fcm example snippets
use Kerox\Fcm\Fcm;
use Kerox\Fcm\Model\Message;
use Kerox\Fcm\Model\Notification\Notification;
use Kerox\Fcm\Model\Target;
$fcm = new Fcm('<oauth_token>', '<project_id>');
// Create the message
$message = new Message(
target: new Token('TopicA'),
data: [
'story_id' => 'story_12345',
],
notification: new Notification(
title: 'Hello World',
body: 'My awesome Hello World!'
),
)
// Send the message and get the response
$response = $fcm->send()->message($message);