1. Go to this page and download the library: Download gfonseca/phpfcm 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/ */
gfonseca / phpfcm example snippets
ne("CONCURRENCY", 50);
define("ACCESS_TOKEN", "google_access_token");
$client_list; // <=list of clients loaded from database
// You also can use PHPFCM\FCMClient::makeMessagePool()
$pack = PHPFCM\FCMClient::makeNotificationPool(
function($client){
return array(
"to" => $client->token,
"message_options" => array(
"dry_run" => false
),
"notification" => array(
"title" => "Hello {$client->name}!",
"body" => "have a look at our offers, Mr. {$client->last_name}! "
)
);
},
$client_list
);
$fcm = new PHPFCM\FCMClient(
ACCESS_TOKEN,
CONCURRENCY
);
$response = $fcm->sendPack($pack);
foreach($response as $r) {
echo $r->getMessageID();
echo "\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.