danielprrazevedo / fcm-php
该软件包分支是基于 pluritech/fcm-php,https://github.com/Pluritech/fcm-php 可移植的PHP 5.3版本
2.0.16
2019-04-26 14:42 UTC
Requires
- php: >=5.3.3
- ext-curl: *
README
该仓库包含一个开源的PHP SDK,允许您从PHP应用程序访问Google FCM平台。
安装
可以使用Composer安装Google FCM PHP SDK。运行以下命令
composer require danielprrazevedo/fcm-php
用法
注意:此版本的Google FCM PHP SDK需要PHP 5.3或更高版本。
简单的推送示例。
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed $FCMPHP = new \FCMPHP\FCMPHP(array( 'fcm_server_key' => '{server-key}' )); $FCMNotification = new \FCMPHP\FCMNotification(); $FCMNotification->setTitle('{push-title}'); $FCMNotification->setBody('{push-description}'); $FCMNotification->setPriority('{push-priority}'); //high or normal $FCMNotification->setDevices(array( '{device-id}' ,'{device-id}' )); //One or more devices $request = $FCMPHP->send($FCMNotification); //Http error if($request->getHttpStatusCode() != 200){ $code = $request->getHttpStatusCode(); $body = $request->getBody(); } //One or more failure on send push to FCM if($failure = $request->hasFailure()){ $count = $failure['count']; $error = $failure['error']; }
文档
进行中。
测试
进行中。
贡献
请随意提交您的拉取请求,对建议做出贡献或报告问题。
许可证
MIT © Guilherme Valentim