腾讯云独立模式账号引入接口
API地址:https://cloud.tencent.com/document/product/269/1608
1、请求地址:
https://console.tim.qq.com/v4/im_open_login_svc/account_import?usersig=xxx&identifier=admin&sdkappid=88888888&random=99999999&contenttype=json
2、请求方式:POST
3、HPPT请求包格式:JSON
4、请求包示例
{
"Identifier":"test",
"Nick":"test",
"FaceUrl":"http://www.qq.com"
}
5、字段说明:
字段 类型 属性 说明
Identifier String 必填 用户名,长度不超过 32 字节
Nick String 选填 用户昵称
FaceUrl String 选填 用户头像URL。
Type Integer 选填 帐号类型,开发者默认无需填写,值0表示普通帐号,1表示机器人帐号。
6、应答包示例:
7、应答包字段说明:
字段 类型 说明
ActionStatus String 请求处理的结果,OK表示处理成功,FAIL表示失败。
ErrorCode Integer 错误码。
ErrorInfo String 错误信息。
8、错误码说明
https://cloud.tencent.com/document/product/269/1671#rest-api.E5.85.AC.E5.85.B1.E9.94.99.E8.AF.AF.E7.A0.81
9、设置APP管理员
https://cloud.tencent.com/document/product/269/16569、PHP代码
function account_sync($uid, $nickName, $photo){
$RTC = Config::getSecret ( 'TENCENT' );
$sdkappid = $RTC['SDKAppid']; //App管理员账号
$admin_account = $RTC['admin_account']; //appID
$usersig = genUserSig($admin_account);
$url = "https://console.tim.qq.com/v4/im_open_login_svc/account_import?usersig={$usersig}&identifier={$admin_account}&sdkappid={$sdkappid}&contenttype=json";
/* $data = [
'Identifier'=> "{$uid}", //用户ID
'Nick' => $nickName,
'FaceUrl' => $photo
]; */
$data['Identifier'] = (string)$uid; //用户ID
if($nickName) $data['Nick'] = $nickName;
if($photo) $data['FaceUrl'] = $photo;
$data = json_encode($data);
curl_php($url, $data);
}