Easemob Restful Api SDK for PHP.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist light/easemob "*"
or add
"light/easemob": "*"
to the require section of your composer.json
file.
use Monolog\Logger;
$easemob = new Easemob([
'enterpriseId' => 'enterpriseID',
'appId' => 'appID',
'clientId' => 'clientID',
'clientSecret' => 'clientSecret',
'log' => [
'file' => '/var/easemob.log',
'level' =>Logger::DEBUG,
],
]);
$user = $easemob->user;
- 注册单个用户
$user->register(['username' => 11, 'password' => 'password'])
- 注册多个用户
$user->register([['username' => 1, 'password' => 'password'], ['username' => 2, 'password' => 'password'])
- 获取单个用户
$user->one(1)
- 获取所有用户
$user->all(/*$cursor*//*, $limit = 20*/)
- 删除单个用户
$user->remove(1)
- 删除多个用户
$user->batchRemove(/*$count = 100*/)
...
$message = $user->message;
//发送文本消息
$text = new \light\Easemob\Message\Text(['msg' => 'hello']);
$message->send($text);
....