Skip to content

设置好友权限 ​

把好友设为正常好友或仅聊天。

接口地址: POST /setFriendPemission

说明与注意 ​

  • 路径就是 setFriendPemission,少一个 r,照原样写。

请求参数 ​

参数名必选类型说明
wId是string登录实例标识
wcId是string好友微信 ID
type是int1 正常,2 仅聊天

请求示例 ​

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

{
  "wId": "f54179d3-26ea-46b5-8aa2-97f02e031a9b",
  "wcId": "LoChaX",
  "type": 1
}
bash
curl -X POST '{BASE_URL}/setFriendPemission' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "wId": "f54179d3-26ea-46b5-8aa2-97f02e031a9b",
  "wcId": "LoChaX",
  "type": 1
}'
python
import requests

url = "{BASE_URL}/setFriendPemission"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "wId": "f54179d3-26ea-46b5-8aa2-97f02e031a9b",
  "wcId": "LoChaX",
  "type": 1
}"""

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}/setFriendPemission";
String body = "{\n" +
    "  \"wId\": \"f54179d3-26ea-46b5-8aa2-97f02e031a9b\",\n" +
    "  \"wcId\": \"LoChaX\",\n" +
    "  \"type\": 1\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}/setFriendPemission';
$body = <<<'JSON'
{
  "wId": "f54179d3-26ea-46b5-8aa2-97f02e031a9b",
  "wcId": "LoChaX",
  "type": 1
}
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
}

响应参数 ​

参数名类型说明
codestring1000 成功;其他值都是失败,通常是 1001
messagestring反馈信息
datanull成功时通常为空