limingxinleo/easemob

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

easemob

1.1.1 2017-01-05 06:20 UTC

This package is auto-updated.

Last update: 2021-09-17 13:10:12 UTC


README

Total Downloads Latest Stable Version Latest Unstable Version License

安装方法

composer require limingxinleo/easemob

使用方法

  • 初始化
use limx\tools\Easemob;
$option = [
    'client_id' => env('EASEMOB_ID'),
    'client_secret' => env('EASEMOB_SECRET'),
    'org_name' => env('EASEMOB_ORG_NAME'),
    'app_name' => env('EASEMOB_APP_NAME'),
];
$easemob = new Easemob($option);
  • 发送环信
$res = $easemob->sendToUsers(['receiver'], 'sender', ['msg' => '环信测试']);
  • 设置StorageAdapter
$easemob->setStorageAdapter(function ($data) {
    $file = BASE_PATH . '/storage/cache/data/huanxin';
    if ($data) {
        // 存储
        file_put_contents($file, $data);
    } else {
        if (file_exists($file)) {
            return file_get_contents($file);
        }
        return false;
    }
});