g9rga/php-fcm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

g9rga/php-fcm

Composer 安装命令:

composer require g9rga/php-fcm

包简介

Php library to send push notification via google fcm

README 文档

README

Status

Build Status

php-fcm

Php library to send push notification via google fcm with guzzle

Usage example

use g9rga\phpFcm\src\AccessToken\FileObtainer;
use g9rga\phpFcm\src\AccessToken\AccessToken;
use g9rga\phpFcm\src\Client;
use g9rga\phpFcm\src\Notification\AndroidNotification;
use g9rga\phpFcm\src\Target\TokenTarget;

/*
    To retrieve access token you can use builtin FileObtainer class
    or your own class by implementeting ObtainerInterface
*/
/*
    File content example:
    {
      "type": "service_account",
      "project_id": "project___",
      "private_key_id": "",
      "private_key": "",
      "client_email": "",
      "client_id": "",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "token_uri": "https://accounts.google.com/o/oauth2/token",
      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
      "client_x509_cert_url": ""
    }

*/
$obtainer = new FileObtainer('crentials_file_path');

$accessToken = new AccessToken($obtainer);

/*
    Optionally you can pass your own PSR-16 cache adapter to cache access token
    InMemoryCache used by default
    $accessToken->setCache();
*/


/*
    Client requires Request adapter to make requests.
    You can use GuzzleRequestAdapter or you own implementation RequestInterface
*/
$guzzleRequest = new GuzzleRequestAdapter();
$guzzleRequest->setGuzzleClient(new \GuzzleHttp\Client());

$target = new TokenTarget('client_token');

$androidNotification = new AndroidNotification();
$androidNotification->setTitle('Push notification title');
$androidNotification->setBody('Push notification body');

$client = new Client($guzzleRequest, $accessToken);
$result = $client->send($target, $androidNotification);

统计信息

  • 总下载量: 2.87k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固