Appearance
获取收藏夹内容
按 favId 获取一条收藏的详情 XML,favId 来自获取收藏夹列表。
接口地址: POST /weChatFavorites/getFavItem
说明与注意
- 不同
type的收藏,objectXML 结构不同,按列表返回的type分别解析。
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| wId | 是 | string | 登录实例标识 |
| favId | 是 | int | 收藏 ID |
请求示例
http
POST {BASE_URL}/weChatFavorites/getFavItem
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"wId": "0000016e-c561-9bbd-0001-3dc796084901",
"favId": 1
}bash
curl -X POST '{BASE_URL}/weChatFavorites/getFavItem' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"wId": "0000016e-c561-9bbd-0001-3dc796084901",
"favId": 1
}'python
import requests
url = "{BASE_URL}/weChatFavorites/getFavItem"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
"wId": "0000016e-c561-9bbd-0001-3dc796084901",
"favId": 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}/weChatFavorites/getFavItem";
String body = "{\n" +
" \"wId\": \"0000016e-c561-9bbd-0001-3dc796084901\",\n" +
" \"favId\": 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}/weChatFavorites/getFavItem';
$body = <<<'JSON'
{
"wId": "0000016e-c561-9bbd-0001-3dc796084901",
"favId": 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
{
"message": "成功",
"code": "1000",
"data": {
"favId": 1,
"object": "<favitem type=\"2\"><source sourcetype=\"1\"><fromusr>wxid_gia1nwcgpobz22</fromusr><tousr>wxid_gia1nwcgpobz22</tousr></source><datalist count=\"1\"><dataitem datatype=\"2\" dataid=\"fe0f5bf7a6e734f10f4c94c1afe8c0e9\"><cdn_thumburl>30500201000449304702010002049c1da4d602033d11fd0204ed3e5b6502045b345cc6042265653239376562613737326138343233383430356466326462356330613266375f740204020027110201000400</cdn_thumburl><cdn_dataurl>304e020100044730450201000204359e277602033d14b90204717124b702045b4d9436042066386135656234396533636365373466353663376130323963393637353564370204020027110201000400</cdn_dataurl><cdn_thumbkey>f3698526452141a298c5a28f8fdf94e2</cdn_thumbkey><cdn_datakey>740d9b78211f47288213c9b6e6fd25b4</cdn_datakey><fullmd5>105062c3583d322f8336f0b38ba286ec</fullmd5><head256md5>5f0455eea82e20d7ba9a377d04aaa35a</head256md5><fullsize>18622</fullsize><thumbfullmd5>e961ae8fcecc36474f0d4a169fc5ade5</thumbfullmd5><thumbhead256md5>d41d8cd98f00b204e9800998ecf8427e</thumbhead256md5><thumbfullsize>12061</thumbfullsize><datadesc></datadesc><datatitle></datatitle></dataitem></datalist><recommendtaglist></recommendtaglist></favitem>",
"updateTime": 1538560491
}
}错误响应
json
{
"message": "失败",
"code": "1001",
"data": null
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | string | 1000 成功;其他值都是失败,通常是 1001 |
| message | string | 反馈信息 |
| data.favId | int | 收藏 ID |
| data.object | xml | 收藏详情 XML |
| data.updateTime | long | 收藏更新时间戳 |