项目作者: mhndev

项目描述 :
simple unified pusher service (pusher.com, pubnub , Fcm , Gcm , Nginx Push Stream Module) all with single interface
高级语言: PHP
项目地址: git://github.com/mhndev/pusher.git
创建时间: 2017-02-15T20:58:34Z
项目社区:https://github.com/mhndev/pusher

开源协议:

下载


Single Interface Multiple Pusher Service

single interface for using multiple pusher service

Included Service

  • FCM
  • GCM
  • Nginx Push Stream Module
  • Pubnub.com
  • Pusher.com

Sample Usage

  1. use mhndev\pusher\PusherFactory;
  2. require 'vendor/autoload.php';
  3. $httpClient = new \GuzzleHttp\Client();
  4. $message = new \mhndev\pusher\Message([
  5. 'name' => 'majid',
  6. 'family' => 'abdolhosseini',
  7. 'age' => 25
  8. ]);
  9. //send message using pusher.com service
  10. $pusherDotComService = PusherFactory::createPusher(
  11. PusherFactory::PUSHER_PUSHERDOTCOM,
  12. ['app_key', 'app_secret', 'app_id', []]
  13. );
  14. $pusherDotComService->push($message, 'device1');
  15. //send message using pubnub.com service
  16. $pubnub = PusherFactory::createPusher(
  17. PusherFactory::PUSHER_PUBNUB,
  18. ['public_key', 'subscribe_key', 'secret_key']
  19. );
  20. $pubnub->push($message, 'device1');
  21. //send message using FCM service
  22. $fcm = PusherFactory::createPusher(
  23. PusherFactory::PUSHER_FCM,
  24. ['api_key', $httpClient]
  25. );
  26. $fcm->push($message, 'device1');
  27. //send message using GCM service
  28. $gcm = PusherFactory::createPusher(
  29. PusherFactory::PUSHER_GCM,
  30. ['api_key']
  31. );
  32. $gcm->push($message, 'device1');
  33. //send message using nginx push stream module
  34. $nginx = PusherFactory::createPusher(
  35. PusherFactory::PUSHER_NGINXMODULE,
  36. [$httpClient, 'http://example.com:8000']
  37. );
  38. $nginx->push($message, 'device1');