jasonwwl / easemob
Easemob RESTful API SDK
1.0.0
2014-10-20 12:27 UTC
Requires
- php: >=5.4.0
- php-curl-class/php-curl-class: ~2.1
This package is auto-updated.
Last update: 2024-09-19 02:47:07 UTC
README
部分接口尚未实现,仅实现了当前项目上使用的接口,有时间会把所有接口都实现出来。
欢迎大家帮我补充剩下的接口。
##Composer 本项目支持Composer安装
$ composer require jasonwwl/easemob
##快速使用 本项目依赖于 php-curl-class/php-curl-class
注意easemob/storage
目录需要可写,因为需要保存token信息
require 'Curl.php'; require 'Easemob.php'; $easemob = new Easemob(array( 'client_id' => '环信client_id', 'client_secret' => '环信client_secret', 'org_name' => 'org_name', 'app_name' => 'app_name' ));
###创建新用户[授权模式]
$easemob->userAuthorizedRegister('username','password');
###查看用户是否在线
$easemob->userOnline('username');
###向群组中添加一个人
$easemob->groupAddUser('group_id','username');
###删除一个用户
$easemob->userDelete('username');
###给指定的群/用户发送消息
考虑到环信的webim目前不支持通过REST方式读取消息的扩展字段ext
,因此在下方的options数组中可以设置mixed键,当设置为true
时,ext
的内容将被格式化为JSON
字符串并放入消息内容中。
群group_id
或用户username
可以是单个String
,也可以是一维数组
群:
$easemob->sendToGroups('group_id','from who?',array( 'mixed' => true, 'ext' => array( 'a' => 'aa', 'b' => 'bb' ) ));
用户:
$easemob->sendToUsers('username','from who?',array( 'mixed' => true, 'ext' => array( 'a' => 'aa', 'b' => 'bb' ) ));
目前仅实现了这些,其余接口欢迎大家增加。