Skip to content

monster-hunter/yii2-easemob-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-easemob-sdk

基于Yii2实现的环信API SDK(目前开发中)

环境条件

  • = PHP 5.4

  • = Yii 2.0

  • = GuzzleHttp 5.0

安装

添加下列代码在composer.json文件中并执行composer update --no-dev操作

{
    "require": {
       "chocoboxxf/yii2-easemob-sdk": "dev-master"
    }
}

设置方法

// 全局使用
// 在config/main.php配置文件中定义component配置信息
'components' => [
  .....
  'easemob' => [
    'class' => 'chocoboxxf\Easemob\Easemob',
    'orgName' => '企业ID',
    'appName' => '应用名称',
    'clientId' => 'Client Id',
    'clientSecret' => 'Client Secret',
  ]
  ....
]
// 代码中调用
$result = Yii::$app->easemob->getUser('username');
....
// 局部调用
$easemob = Yii::createObject([
    'class' => 'chocoboxxf\Easemob\Easemob',
    'orgName' => '企业ID',
    'appName' => '应用名称',
    'clientId' => 'Client Id',
    'clientSecret' => 'Client Secret',
]);
$result = $easemob->getUser('username');
....

使用示例

创建单个用户

$userInfo = Yii::$app->easemob->createUser('username', 'password', 'nickname');

获取单个用户

$userInfo = Yii::$app->easemob->getUser('username');

获取用户Access Token

$tokenInfo = Yii::$app->easemob->getUserToken('username', 'password');

添加好友

$friendInfo = Yii::$app->easemob->addFriend('username1', 'username2');

导出聊天记录

$data = Yii::$app->easemob->exportChatMessages();

发送透传消息

$data = Yii::$app->easemob->sendCmd('users', ['user1', 'users2'], 'action1', ['key1' => 'value1'], 'admin');

About

基于Yii2实现的环信API SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%