1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Common\Library;
- use Easemob\Auth;
- use Easemob\Push;
- class Easemob {
- protected $auth;
- public function __construct() {
- //环信推送 正式
- $easemob_config = [
- 'appkey' => '1137221110163975#tkenim',
- 'client_id' => 'YXA6DEehGBpFTb-UOcgmWtveZQ',
- 'client_secret' => 'YXA6KhfJfqyJYBn2I20DdgTEzWpx5Cs',
- ];
- //初始化配置
- // $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'=> 0,
- 'setNum'=> 0,
- ],
- ],
- 'easemob'=>[],
- 'apns'=> [],
- 'fcm'=> [],
- 'fcmV1'=>[],
- 'huawei'=> [],
- 'meizu'=> [],
- 'oppo'=> [],
- 'vivo'=> [],
- 'xiaomi'=> [],
- 'honor'=>[]*/
- ];
- $rs = $message->push_sync($uid,$pushMessage);
- return $rs;
- //dump($rs);
- }
- }
|