Skip to content

修改联系人标签 ​

设置某个好友的标签,labelIdList 传这个好友修改后的全部标签 ID。

接口地址: POST /modifyContactLabel

说明与注意 ​

  • 传的是最终列表,会整体替换好友原有的标签,不是增量加减。给好友加或减一个标签,都要先查出他当前的全部标签 ID,算出结果再传。
  • 批量加减标签要逐个好友算最终列表、分别调用。
  • 标签 ID 用获取标签列表查。

请求参数 ​

参数名必选类型说明
wId是string登录实例标识
wcId是string好友微信 ID
labelIdList是string最终标签 ID 列表,多个标签用英文逗号分隔

请求示例 ​

http
POST {BASE_URL}/modifyContactLabel
Authorization: Bearer <你的调用凭证>
Content-Type: application/json

{
  "wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
  "wcId": "wxid_jg6e5v0b8bp322",
  "labelIdList": "1,2"
}
bash
curl -X POST '{BASE_URL}/modifyContactLabel' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
  "wcId": "wxid_jg6e5v0b8bp322",
  "labelIdList": "1,2"
}'
python
import requests

url = "{BASE_URL}/modifyContactLabel"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
  "wcId": "wxid_jg6e5v0b8bp322",
  "labelIdList": "1,2"
}"""

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}/modifyContactLabel";
String body = "{\n" +
    "  \"wId\": \"349be9b5-8734-45ce-811d-4e10ca568c67\",\n" +
    "  \"wcId\": \"wxid_jg6e5v0b8bp322\",\n" +
    "  \"labelIdList\": \"1,2\"\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}/modifyContactLabel';
$body = <<<'JSON'
{
  "wId": "349be9b5-8734-45ce-811d-4e10ca568c67",
  "wcId": "wxid_jg6e5v0b8bp322",
  "labelIdList": "1,2"
}
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
{
 "message": "成功",
 "code": "1000",
 "data": null
}

错误响应 ​

json
{
 "message": "失败",
 "code": "1001",
 "data": null
}

响应参数 ​

参数名类型说明
codestring1000 成功;其他值都是失败,通常是 1001
messagestring反馈信息
datanull无业务数据返回