hxc / im-laravel
Laravel+腾讯云通信服务端api
dev-master
2023-06-05 03:49 UTC
Requires
- guzzlehttp/guzzle: ~7.0
- tencent/tls-sig-api-v2: ^1.0
This package is auto-updated.
Last update: 2025-03-05 07:42:45 UTC
README
安装方法
composer require hxc/im
使用方法
-
在
application/config.php
中增加配置信息:'im' => [ 'appid' => '云通信appid', 'admin' => '帐号管理员用户名', 'secret' => '云通信密钥', 'domain' => 'https://console.tim.qq.com',//请求的域名,无特殊情况不用修改 'fun_arr' => [ //格式举例: //'account_import' => '/v4/im_open_login_svc/account_import',//单个帐号导入 ],//请求接口数组,如果遇到报错为:暂未封装此方法,可根据文档自己封装。(文档:https://cloud.tencent.com/document/product/269/1519),可在此处添加 ],
-
调用
//获取配置 $config = Config::get('im'); //账号导入 $res = json_decode(IM::TX($config)->fun('account_import', [ "Identifier" => '用户名,长度不超过32字节', "Nick" => '用户昵称', "FaceUrl" => '用户头像 URL' ])->post(), true); if ($res['ActionStatus'] !== 'OK' || $res['ErrorCode'] !== 0) { $this->returnFail('登录失败:通讯连接失败'); } //生成签名 IM::TX($config)->user($data['account'])->genSig();