Appearance
获取联系人详情
批量查询好友或群聊的昵称、头像、备注、标签和加好友凭证 v1。
接口地址: POST /getContact
说明与注意
- 批量查询时每次调用间隔 300-800ms。
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
wId | 是 | string | 登录实例标识 |
wcId | 是 | string | 好友微信 ID 或群 ID;多个用英文逗号分隔,单次最多 20 个 |
请求示例
http
POST {BASE_URL}/getContact
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
"wcId": "LoChaX,wxid_wl9qchkanp9u22"
}bash
curl -X POST '{BASE_URL}/getContact' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
"wcId": "LoChaX,wxid_wl9qchkanp9u22"
}'python
import requests
url = "{BASE_URL}/getContact"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
"wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
"wcId": "LoChaX,wxid_wl9qchkanp9u22"
}"""
resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String url = "{BASE_URL}/getContact";
String body = "{\n" +
" \"wId\": \"349be9b5-8734-45ce-811d-4e10ca568c67\",\n" +
" \"wcId\": \"LoChaX,wxid_wl9qchkanp9u22\"\n" +
"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer <你的调用凭证>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());php
<?php
$url = '{BASE_URL}/getContact';
$body = <<<'JSON'
{
"wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
"wcId": "LoChaX,wxid_wl9qchkanp9u22"
}
JSON;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <你的调用凭证>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;成功响应
json
{
"code": "1000",
"message": "成功",
"data": [
{
"userName": "test558666",
"nickName": "追风少年666",
"remark": "",
"signature": "66666",
"sex": 1,
"aliasName": "test558666",
"country": "CN",
"bigHead": "https://wx.qlogo.cn/mmhead/AbCdEfGhIjKlMnOpQrStUv/0",
"smallHead": "https://wx.qlogo.cn/mmhead/AbCdEfGhIjKlMnOpQrStUv/132",
"labelList": "",
"v1": "v1_584e7774024c79af..."
}
]
}错误响应
json
{
"code": "1001",
"message": "失败",
"data": null
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
code | string | 1000 成功;其他值都是失败,通常是 1001 |
message | string | 反馈信息 |
data | array | 联系人信息列表 |
data[].userName | string | 微信原始 ID |
data[].nickName | string | 昵称 |
data[].remark | string | 备注名 |
data[].aliasName | string | 微信号,用户设置后返回 |
data[].signature | string | 个性签名 |
data[].sex | int | 性别:1 男、2 女、0 未知 |
data[].country | string | 国家编码 |
data[].bigHead | string | 大头像 URL |
data[].smallHead | string | 小头像 URL |
data[].labelList | string | 标签 ID 列表 |
data[].v1 | string | 加好友凭证,可搭配添加好友接口使用 |