123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace app\common\library;
- use Easemob\Auth;
- use Easemob\Push;
- class Easemob {
- protected $auth;
- public function __construct() {
- //初始化配置
- $easemob_config = config('easemob');
- $appKey = $easemob_config['appkey'];
- $clientIdOrAppID = $easemob_config['client_id'];
- $clientSecretOrAppCertificate = $easemob_config['client_secret'];
- $this->auth = new Auth($appKey,$clientIdOrAppID,$clientSecretOrAppCertificate);
- }
- //////////////////消息推送//////////////////////////
- public function push_text($uid,$title,$msg){
- $message = new Push($this->auth);
- $pushMessage =
- [
- 'title'=> $title,
- // 'subTitle'=> '',
- 'content'=> $msg,
- // 'ext'=> [],
- /* 'config'=> [
- 'clickAction'=> [
- 'url'=>'',
- 'action'=>'',
- 'activity'=>'',
- ],
- 'badge'=> [
- 'addNum'=> 1,
- 'setNum'=> 0,
- ],
- ],*/
- ///'easemob'=>[],
- /*'apns'=> [
- 'badge'=> 1,
- ],*/
- /*'fcm'=> [],
- 'fcmV1'=>[],
- 'huawei'=> [],
- 'meizu'=> [],
- 'oppo'=> [],
- 'vivo'=> [],
- 'xiaomi'=> [],
- 'honor'=>[]*/
- ];
- $rs = $message->push_sync($uid,$pushMessage);
- //dump($rs);
- }
- public function push_all($title,$msg){
- $message = new Push($this->auth);
- $pushMessage =
- [
- 'title'=> $title,
- // 'subTitle'=> '',
- 'content'=> $msg,
- // 'ext'=> [],
- /* 'config'=> [
- 'clickAction'=> [
- 'url'=>'',
- 'action'=>'',
- 'activity'=>'',
- ],
- 'badge'=> [
- 'addNum'=> 1,
- 'setNum'=> 0,
- ],
- ],*/
- ///'easemob'=>[],
- /*'apns'=> [
- 'badge'=> 1,
- ],*/
- /*'fcm'=> [],
- 'fcmV1'=>[],
- 'huawei'=> [],
- 'meizu'=> [],
- 'oppo'=> [],
- 'vivo'=> [],
- 'xiaomi'=> [],
- 'honor'=>[]*/
- ];
- $rs = $message->push_task($pushMessage);
- //dump($rs);
- }
- }
|