用户文章
获取知乎用户发布的文章,具有偏移分页和发布时间或点赞排序功能。用于按所选顺序浏览创作者的文章。
参数
| 参数 | 必填 | 类型 | 说明 | 示例 | 可选值 |
|---|---|---|---|---|---|
user_url_token |
必填 | string | 知乎用户URL令牌,例如 `zhihu.com/people/{userUrlToken}` 中的值。 | zhang-jia-wei |
— |
offset |
可选 | integer | 起始偏移量,从0开始。 | 0 |
— |
sort_type |
可选 | string | 用户文章的排序标准。 可用值: - `created`:按发布时间排序。 - `voteups`:按赞同数排序。 | created |
createdvoteups |
代码示例
curl -G "https://api.mofa-ai.com/v1/zhihu/get_user_articles_v1" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'user_url_token=zhang-jia-wei' \
--data-urlencode 'offset=0' \
--data-urlencode 'sort_type=created'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/zhihu/get_user_articles_v1",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"user_url_token": "zhang-jia-wei",
"offset": "0",
"sort_type": "created",
},
timeout=60,
)
body = resp.json()
if body["success"]:
print(body["cost_usd"], body["data"])
else:
print(body["error"], body["message"])
const url = new URL("https://api.mofa-ai.com/v1/zhihu/get_user_articles_v1");
url.search = new URLSearchParams({
user_url_token: "zhang-jia-wei",
offset: "0",
sort_type: "created",
});
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.MOFA_API_KEY}` },
});
const body = await resp.json();
if (body.success) console.log(body.cost_usd, body.data);
else console.error(body.error, body.message);
在线试用
登录后可以在这里直接调用此接口,按价格从余额扣费,失败不收费。新账户赠送 $0.50 试用额度。
响应示例
这个接口暂无响应示例。