Appearance
发布朋友圈
用当前账号发一条客户朋友圈,支持纯文本 / 图文 / 视频 + 可见范围 + 位置。
请求参数
| 参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
appid | 是 | string | 实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx |
xid | 否 | array<object> | 可见范围用户 id 列表。示例:[] |
content | 是 | string | 文字内容。示例:测下100 |
mediaList | 否 | array<object> | 媒体列表(见下)。无媒体时字段缺省。示例:[{"type":2,"fileId":"*1*<大文件 id>","videoLen":1,"md5":"f93… |
poiInfo | 否 | object | 位置。示例:{"city":"汕尾市","latitude":"-180","longitude":"-180","poiAd… |
linkInfo | 否 | object | 链接。示例:{} |
visibleType | 否 | boolean | 可见类型。示例:false |
isGroupSend | 否 | boolean | 是否群发。示例:false |
mediaList[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
mediaList[].type | int64 | 类型编码 |
mediaList[].fileId | string | CDN 文件业务标识(即 id) |
mediaList[].videoLen | int64 | 视频时长(秒),仅 type=2 |
mediaList[].md5 | string | 文件内容 MD5,收发方一致性校验 |
mediaList[].size | int64 | 文件字节数 |
mediaList[].storeType | int64 | 存储类型,通常 0 |
poiInfo 字段
| 字段 | 类型 | 说明 |
|---|---|---|
poiInfo.city | string | |
poiInfo.latitude | string | 纬度 |
poiInfo.longitude | string | 经度 |
poiInfo.poiAddress | string | |
poiInfo.poiClassifyId | string | |
poiInfo.poiClassifyType | string |
请求示例
http
POST {BASE_URL}/wx-api/api/friend/sendSns
Authorization: Bearer <你的 App Token>
Content-Type: application/json
{
"appid": "we_xxxxxxxxxxxxxxx",
"xid": [],
"content": "测下100",
"mediaList": [
{
"type": 2,
"fileId": "*1*<大文件 id>",
"videoLen": 1,
"md5": "f93dc595ca1a990d94aa8330ff31c318",
"size": 369520,
"storeType": 0
},
{
"type": 3,
"fileId": "*1*<大文件 id>",
"md5": "7cb5c01f3809f277fc522cad774fadae",
"size": 10782,
"storeType": 0
}
],
"poiInfo": {
"city": "汕尾市",
"latitude": "-180",
"longitude": "-180",
"poiAddress": "",
"poiClassifyId": "",
"poiClassifyType": ""
},
"linkInfo": {},
"visibleType": false,
"isGroupSend": false
}bash
curl -X POST '{BASE_URL}/wx-api/api/friend/sendSns' \
-H 'Authorization: Bearer <你的 App Token>' \
-H 'Content-Type: application/json' \
--data-raw '{
"appid": "we_xxxxxxxxxxxxxxx",
"xid": [],
"content": "测下100",
"mediaList": [
{
"type": 2,
"fileId": "*1*<大文件 id>",
"videoLen": 1,
"md5": "f93dc595ca1a990d94aa8330ff31c318",
"size": 369520,
"storeType": 0
},
{
"type": 3,
"fileId": "*1*<大文件 id>",
"md5": "7cb5c01f3809f277fc522cad774fadae",
"size": 10782,
"storeType": 0
}
],
"poiInfo": {
"city": "汕尾市",
"latitude": "-180",
"longitude": "-180",
"poiAddress": "",
"poiClassifyId": "",
"poiClassifyType": ""
},
"linkInfo": {},
"visibleType": false,
"isGroupSend": false
}'python
import requests
url = "{BASE_URL}/wx-api/api/friend/sendSns"
headers = {"Authorization": "Bearer <你的 App Token>", "Content-Type": "application/json"}
body = """{
"appid": "we_xxxxxxxxxxxxxxx",
"xid": [],
"content": "测下100",
"mediaList": [
{
"type": 2,
"fileId": "*1*<大文件 id>",
"videoLen": 1,
"md5": "f93dc595ca1a990d94aa8330ff31c318",
"size": 369520,
"storeType": 0
},
{
"type": 3,
"fileId": "*1*<大文件 id>",
"md5": "7cb5c01f3809f277fc522cad774fadae",
"size": 10782,
"storeType": 0
}
],
"poiInfo": {
"city": "汕尾市",
"latitude": "-180",
"longitude": "-180",
"poiAddress": "",
"poiClassifyId": "",
"poiClassifyType": ""
},
"linkInfo": {},
"visibleType": false,
"isGroupSend": false
}"""
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}/wx-api/api/friend/sendSns";
String body = "{\n" +
" \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
" \"xid\": [],\n" +
" \"content\": \"测下100\",\n" +
" \"mediaList\": [\n" +
" {\n" +
" \"type\": 2,\n" +
" \"fileId\": \"*1*<大文件 id>\",\n" +
" \"videoLen\": 1,\n" +
" \"md5\": \"f93dc595ca1a990d94aa8330ff31c318\",\n" +
" \"size\": 369520,\n" +
" \"storeType\": 0\n" +
" },\n" +
" {\n" +
" \"type\": 3,\n" +
" \"fileId\": \"*1*<大文件 id>\",\n" +
" \"md5\": \"7cb5c01f3809f277fc522cad774fadae\",\n" +
" \"size\": 10782,\n" +
" \"storeType\": 0\n" +
" }\n" +
" ],\n" +
" \"poiInfo\": {\n" +
" \"city\": \"汕尾市\",\n" +
" \"latitude\": \"-180\",\n" +
" \"longitude\": \"-180\",\n" +
" \"poiAddress\": \"\",\n" +
" \"poiClassifyId\": \"\",\n" +
" \"poiClassifyType\": \"\"\n" +
" },\n" +
" \"linkInfo\": {},\n" +
" \"visibleType\": false,\n" +
" \"isGroupSend\": false\n" +
"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer <你的 App Token>")
.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}/wx-api/api/friend/sendSns';
$body = <<<'JSON'
{
"appid": "we_xxxxxxxxxxxxxxx",
"xid": [],
"content": "测下100",
"mediaList": [
{
"type": 2,
"fileId": "*1*<大文件 id>",
"videoLen": 1,
"md5": "f93dc595ca1a990d94aa8330ff31c318",
"size": 369520,
"storeType": 0
},
{
"type": 3,
"fileId": "*1*<大文件 id>",
"md5": "7cb5c01f3809f277fc522cad774fadae",
"size": 10782,
"storeType": 0
}
],
"poiInfo": {
"city": "汕尾市",
"latitude": "-180",
"longitude": "-180",
"poiAddress": "",
"poiClassifyId": "",
"poiClassifyType": ""
},
"linkInfo": {},
"visibleType": false,
"isGroupSend": false
}
JSON;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <你的 App Token>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;响应示例
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
code | int64 | 统一封套状态码:0=成功,负数=失败 |
detail | string | 附加明细,通常为空 |
message | string | 文案:成功为 ok;失败形如 -码|描述 |
time | string | 服务端处理时间 YYYY-MM-DD HH:MM:SS |