Appearance
发送文字朋友圈
发布一条纯文本朋友圈。
调用限制
微信需在线三天后使用本接口,否则微信团队会提示不可使用副设备发送。
接口地址: POST /snsSend
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| wId | 是 | string | 登录实例标识 |
| content | 是 | string | 文本内容 |
| groupUser | 否 | string | 可见用户微信 ID,多个用英文逗号分隔。和 blackList 只能传一个,都传会返回「部分可见/不给谁看 仅可传其一。」 |
| blackList | 否 | string | 不可见用户微信 ID,多个用英文逗号分隔。和 groupUser 只能传一个 |
| groupUserLabelIds | 否 | string | 可见标签 ID,多个用英文逗号分隔 |
| blackListLabelIds | 否 | string | 不可见标签 ID,多个用英文逗号分隔 |
请求示例
http
POST {BASE_URL}/snsSend
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"wId": "0000016e-6343-089e-0001-e2ef939176f6",
"content": "这是一条文本朋友圈消息"
}bash
curl -X POST '{BASE_URL}/snsSend' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"wId": "0000016e-6343-089e-0001-e2ef939176f6",
"content": "这是一条文本朋友圈消息"
}'python
import requests
url = "{BASE_URL}/snsSend"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
"wId": "0000016e-6343-089e-0001-e2ef939176f6",
"content": "这是一条文本朋友圈消息"
}"""
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}/snsSend";
String body = "{\n" +
" \"wId\": \"0000016e-6343-089e-0001-e2ef939176f6\",\n" +
" \"content\": \"这是一条文本朋友圈消息\"\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}/snsSend';
$body = <<<'JSON'
{
"wId": "0000016e-6343-089e-0001-e2ef939176f6",
"content": "这是一条文本朋友圈消息"
}
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": {
"id": "13200538655176208452",
"userName": "wxid_6mq1pu8ngj3r22",
"createTime": 1573626834,
"objectDesc": "这是一条文本朋友圈消息"
}
}错误响应
json
{
"message": "失败",
"code": "1001",
"data": null
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | string | 1000 成功;其他值都是失败,通常是 1001 |
| message | string | 反馈信息 |
| data.id | string | 朋友圈 ID |
| data.userName | string | 发送者微信 ID |
| data.createTime | long | 发布时间戳 |
| data.objectDesc | string | 朋友圈内容 |