有奖捉虫:云通信与企业服务文档专题,速来> HOT

功能说明

支持拉取好友和非好友的资料字段。
建议每次拉取的用户数不超过100,避免因回包数据量太大导致回包失败。
请确保请求中的所有账号都已导入即时通信 IM,如果请求中含有未导入即时通信 IM 的账号,即时通信 IM 后台将会提示错误。

接口调用说明

请求 URL 示例

https://xxxxxx/v4/profile/portrait_get?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json

请求参数说明

下表仅列出调用本接口时涉及修改的参数及其说明,更多参数详情请参考 REST API 简介
参数
说明
xxxxxx
SDKAppID 所在国家/地区对应的专属域名:
中国:console.tim.qq.com
新加坡:adminapisgp.im.qcloud.com
首尔: adminapikr.im.qcloud.com
法兰克福:adminapiger.im.qcloud.com
孟买:adminapiind.im.qcloud.com
硅谷:adminapiusa.im.qcloud.com
雅加达:adminapiidn.im.qcloud.com
v4/profile/portrait_get
请求接口
sdkappid
创建应用时即时通信 IM 控制台分配的 SDKAppID
identifier
必须为 App 管理员账号,更多详情请参见 App 管理员
usersig
App 管理员账号生成的签名,具体操作请参见 生成 UserSig
random
请输入随机的32位无符号整数,取值范围0 - 4294967295
contenttype
请求格式固定值为json

最高调用频率

200次/秒。

请求包示例

读一个用户的一个资料字段
{
"To_Account":["id1"],
"TagList":
[
"Tag_Profile_IM_Nick"
]
}
读一个用户的多个资料字段
{
"To_Account":["id1"],
"TagList":
[
"Tag_Profile_IM_Nick",
"Tag_Profile_IM_AllowType",
"Tag_Profile_IM_SelfSignature",
"Tag_Profile_Custom_Test"
]
}
读多个用户的一个资料字段
{
"To_Account":["id1","id2","id3"],
"TagList":
[
"Tag_Profile_IM_Nick"
]
}
读多个用户的多个资料字段
{
"To_Account":["id1","id2","id3","id4"],
"TagList":
[
"Tag_Profile_IM_Nick",
"Tag_Profile_IM_AllowType",
"Tag_Profile_IM_SelfSignature",
"Tag_Profile_Custom_Test"
]
}

请求包字段说明

字段
类型
属性
说明
To_Account
Array
必填
需要拉取这些 UserID 的资料。
注意:每次拉取的用户数不得超过100,避免因回包数据量太大以致回包失败。
TagList
Array
必填
指定要拉取的资料字段的 Tag,支持的字段有:
标配资料字段,详情可参见 标配资料字段
自定义资料字段,详情可参见 自定义资料字段

应答包体示例

读一个用户的一个资料字段
{
"UserProfileItem":
[
{
"To_Account":"id1",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest1"
}
],
"ResultCode":0,
"ResultInfo":""
}
],
"ActionStatus":"OK",
"ErrorCode":0,
"ErrorInfo":"",
"ErrorDisplay":""
}
读一个用户的多个资料字段
{
"UserProfileItem":
[
{
"To_Account":"id1",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest1"
},
{
"Tag":"Tag_Profile_IM_AllowType",
"Value":"AllowType_Type_NeedConfirm"
},
{
"Tag":"Tag_Profile_IM_SelfSignature",
"Value":"I'm Test1"
},
{
"Tag":"Tag_Profile_Custom_Test",
"Value":"Custom Data1"
}
],
"ResultCode":0,
"ResultInfo":""
}
],
"ActionStatus":"OK",
"ErrorCode":0,
"ErrorInfo":"",
"ErrorDisplay":""
}
读多个用户的一个资料字段
{
"UserProfileItem":
[
{
"To_Account":"id1",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest1"
}
],
"ResultCode":0,
"ResultInfo":""
},
{
"To_Account":"id2",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest2"
}
],
"ResultCode":0,
"ResultInfo":""
},
{
"To_Account":"id3",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest3"
}
],
"ResultCode":0,
"ResultInfo":""
}
],
"ActionStatus":"OK",
"ErrorCode":0,
"ErrorInfo":"",
"ErrorDisplay":""
}
读多个用户的多个资料字段
{
"UserProfileItem":
[
{
"To_Account":"id1",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest1"
},
{
"Tag":"Tag_Profile_IM_AllowType",
"Value":"AllowType_Type_NeedConfirm"
},
{
"Tag":"Tag_Profile_IM_SelfSignature",
"Value":"I'm Test1"
},
{
"Tag":"Tag_Profile_Custom_Test",
"Value":"Custom Data1"
}
],
"ResultCode":0,
"ResultInfo":""
},
{
"To_Account":"id2",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest2"
},
{
"Tag":"Tag_Profile_IM_AllowType",
"Value":"AllowType_Type_DenyAny"
},
{
"Tag":"Tag_Profile_IM_SelfSignature",
"Value":"I'm Test2"
},
{
"Tag":"Tag_Profile_Custom_Test",
"Value":"Custom Data2"
}
],
"ResultCode":0,
"ResultInfo":""
},
{
"To_Account":"id3",
"ProfileItem":
[
{
"Tag":"Tag_Profile_IM_Nick",
"Value":"NickNameTest3"
},
{
"Tag":"Tag_Profile_IM_AllowType",
"Value":"AllowType_Type_AllowAny"
},
{
"Tag":"Tag_Profile_IM_SelfSignature",
"Value":"I'm Test3"
},
{
"Tag":"Tag_Profile_Custom_Test",
"Value":"Custom Data3"
}
],
"ResultCode":0,
"ResultInfo":""
},
{
"To_Account":"id4",
"ResultCode":40006,
"ResultInfo":"Err_Profile_PortraitGet_Read_Custom_Data_Fail"
}
],
"Fail_Account":["id4"],
"ActionStatus":"OK",
"ErrorCode":0,
"ErrorInfo":"",
"ErrorDisplay":""
}

应答包字段说明

字段
类型
说明
UserProfileItem
Array
返回的用户资料结构化信息
To_Account
String
返回的用户的 UserID
ProfileItem
Array
返回的用户的资料对象数组,数组中每一个对象都包含了 Tag 和 Value
Tag
String
返回的资料对象的名称:
1. 标配资料字段,详情可参见 标配资料字段
2. 自定义资料字段,详情可参见 自定义资料字段
Value
uint64_t/string/bytes
拉取的资料对象的值,详情可参见 资料字段
ResultCode
Integer
To_Account 的处理结果:
0:表示成功
非0:表示失败
ResultInfo
String
To_Account 的错误描述信息,成功时该字段为空
Fail_Account
Array
返回处理失败的用户列表,仅当存在失败用户时才返回该字段
ActionStatus
String
请求处理的结果:
OK:表示处理成功
FAIL:表示失败
ErrorCode
Integer
错误码:
0:表示成功
非0:表示失败
ErrorInfo
String
详细错误信息
ErrorDisplay
String
详细的客户端展示信息

错误码说明

除非发生网络错误(例如502错误),否则该接口的 HTTP 返回码均为200。真正的错误码,错误信息是通过应答包体中的 ErrorCode、ErrorInfo 来表示的。 公共错误码(60000到79999)参见 错误码 文档。 本 API 私有错误码如下:
错误码
描述
40001
请求参数错误,请根据错误描述检查请求参数
40002
请求参数错误,没有指定 To_Account
40003
请求的用户账号不存在
40004
请求需要 App 管理员权限
40006
服务器内部错误,请稍后重试
40007
没有资料字段的读权限,详情可参见 资料字段
40009
资料字段的 Tag 不存在

接口调试工具

通过 REST API 在线调试 工具调试本接口。

参考

设置资料(v4/profile/portrait_set