Skip to content

发送图片朋友圈 ​

发布图文朋友圈。

调用限制

微信需在线三天后使用本接口,否则微信团队会提示不可使用副设备发送。

接口地址: POST /snsSendImage

说明与注意 ​

  • paths 里的图片 URL 要公网可访问。
  • 单张图片 3M 以内,PNG 格式。

请求参数 ​

参数名必选类型说明
wId是string登录实例标识
content是string文本内容
paths是string图片 URL,多个用英文分号分隔
groupUser否string可见用户微信 ID,多个用英文逗号分隔。和 blackList 只能传一个,都传会返回「部分可见/不给谁看 仅可传其一。」
blackList否string不可见用户微信 ID,多个用英文逗号分隔。和 groupUser 只能传一个
groupUserLabelIds否string可见标签 ID,多个用英文逗号分隔
blackListLabelIds否string不可见标签 ID,多个用英文逗号分隔

请求示例 ​

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

{
 "wId": "0000016e-6382-4be4-0001-e6b4e3cd1bbd",
 "content": "这是一条图文朋友圈消息",
 "paths": "http://1563240615548.jpg;http://1563253424796.png"
}
bash
curl -X POST '{BASE_URL}/snsSendImage' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
 "wId": "0000016e-6382-4be4-0001-e6b4e3cd1bbd",
 "content": "这是一条图文朋友圈消息",
 "paths": "http://1563240615548.jpg;http://1563253424796.png"
}'
python
import requests

url = "{BASE_URL}/snsSendImage"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
 "wId": "0000016e-6382-4be4-0001-e6b4e3cd1bbd",
 "content": "这是一条图文朋友圈消息",
 "paths": "http://1563240615548.jpg;http://1563253424796.png"
}"""

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}/snsSendImage";
String body = "{\n" +
    " \"wId\": \"0000016e-6382-4be4-0001-e6b4e3cd1bbd\",\n" +
    " \"content\": \"这是一条图文朋友圈消息\",\n" +
    " \"paths\": \"http://1563240615548.jpg;http://1563253424796.png\"\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}/snsSendImage';
$body = <<<'JSON'
{
 "wId": "0000016e-6382-4be4-0001-e6b4e3cd1bbd",
 "content": "这是一条图文朋友圈消息",
 "paths": "http://1563240615548.jpg;http://1563253424796.png"
}
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": {
 "status": 1,
 "object": {
 "id": "13367129656153944194",
 "userName": "wxid_gia1nwcgpobz22",
 "createTime": 1593486029,
 "objectDesc": "这是一条图文朋友圈消息"
 }
 }
}

错误响应 ​

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

响应参数 ​

参数名类型说明
codestring1000 成功;其他值都是失败,通常是 1001
messagestring反馈信息
data.statusint发送状态
data.object.idstring朋友圈 ID
data.object.userNamestring发送者微信 ID
data.object.createTimelong发布时间戳
data.object.objectDescstring朋友圈内容