Appearance
个人隐私设置
设置微信实例的加好友验证、通讯录推荐和添加方式开关。
接口地址: POST /userPrivacySettings
说明与注意
- 每次只能设置一项,多项分多次调用。
- 手机端显示有延迟,约 30 秒后重启微信再看。
privacyType 取值说明
| 值 | 含义 |
|---|---|
4 | 加我为朋友时需要验证 |
7 | 向我推荐通讯录朋友 |
8 | 添加方式:手机号 |
25 | 添加方式:微信号 |
38 | 添加方式:群聊 |
39 | 添加方式:二维码 |
40 | 添加方式:名片 |
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
wId | 是 | string | 登录实例标识 |
privacyType | 是 | int | 隐私项目,见下方取值说明 |
switchType | 是 | int | 1 关闭,2 开启 |
请求示例
http
POST {BASE_URL}/userPrivacySettings
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"wId": "01377f33-544c-4dc4-9184-bcbbcd3b05d0",
"privacyType": 4,
"switchType": 2
}bash
curl -X POST '{BASE_URL}/userPrivacySettings' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"wId": "01377f33-544c-4dc4-9184-bcbbcd3b05d0",
"privacyType": 4,
"switchType": 2
}'python
import requests
url = "{BASE_URL}/userPrivacySettings"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
"wId": "01377f33-544c-4dc4-9184-bcbbcd3b05d0",
"privacyType": 4,
"switchType": 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}/userPrivacySettings";
String body = "{\n" +
" \"wId\": \"01377f33-544c-4dc4-9184-bcbbcd3b05d0\",\n" +
" \"privacyType\": 4,\n" +
" \"switchType\": 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}/userPrivacySettings';
$body = <<<'JSON'
{
"wId": "01377f33-544c-4dc4-9184-bcbbcd3b05d0",
"privacyType": 4,
"switchType": 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
{
"code": "1000",
"message": "成功",
"data": null
}错误响应
json
{
"code": "1001",
"message": "失败",
"data": null
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
code | string | 1000 成功;其他值都是失败,通常是 1001 |
message | string | 反馈信息 |
data | null | 成功或失败时通常为空 |