微博帖子详情 API (V1)
接口健康状态
健康 可用 少量可用 基本不可用 暂无数据
正在加载健康状态…
检索通过帖子ID标识的微博帖子详情。用于查找已知帖子,以进行内容审查、存档或相关互动分析。
请求参数
| 参数名 | 位置 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|---|
token | query | string | 是 | - | API 访问令牌。 |
id | query | string | 是 | - | 微博帖子ID。 |
代码示例
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE'text
我想使用 JustOneAPI 提供的“帖子详情 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路径: /api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE
接口地址: BASE_URL + /api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE
HTTP 方法: GET
身份验证: 在 URL 中传入 token 查询参数。
OpenAPI 定义: https://docs.justoneapi.com/openapi/weibo/post-details-v1-zh.json
请求参数说明:
- token (query): API 访问令牌。 (必填)
- id (query): 微博帖子ID。 (必填)
返回格式: 请根据实际 Content-Type 安全处理 JSON 或文本响应。
响应处理与错误码:
1. 需通过返回体中的 "code" 字段判断业务结果(code 为 0 表示成功)。
2. 超时建议:建议将请求超时时间设置为 120 秒;如果 120 秒偏长,请至少设置为 60 秒,但可能会有少量请求因超时而未接收到结果。
3. 业务码说明:
- 0: 成功
- 100: Token 无效或已失效
- 301: 采集失败,请重试
- 302: 超出速率限制
- 303: 超出每日配额
- 400: 参数错误
- 500: 内部服务器错误
- 600: 权限不足
- 601: 账户余额不足
- 602: TOKEN 限额超限
4. code 601 表示账户共享余额不足。code 602 表示当前 API TOKEN 自身的累计消费上限已达到。TOKEN 限额不是资金划拨,多个 TOKEN 仍共享同一个账户余额。
请帮我用我擅长的编程语言写一个脚本来调用这个接口,并处理返回结果。python
import requests
BASE_URL = "https://api.justoneapi.com" # 由 OpenAPI servers 提供
url = BASE_URL + "/api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
content_type = response.headers.get("content-type", "").lower()
if "json" in content_type:
try:
print(response.json())
except ValueError:
print(response.text)
elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
print(response.text)
else:
with open("response.bin", "wb") as output:
output.write(response.content)
print(f"Saved {len(response.content)} bytes to response.bin")js
const BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
const url = BASE_URL + "/api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE";
const response = await fetch(url, {
method: "GET",
signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
const contentType = (response.headers.get("content-type") || "").toLowerCase();
const mediaType = contentType.split(";", 1)[0].trim();
const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
if (textual) {
const responseText = new TextDecoder().decode(responseBytes);
let data = responseText;
if (contentType.includes("json")) {
try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
}
console.log(data);
} else {
console.log(`Received ${responseBytes.byteLength} binary bytes`);
}
}java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws Exception {
final String BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
final String url = BASE_URL + "/api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE";
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(120))
.method("GET", HttpRequest.BodyPublishers.noBody());
HttpRequest request = builder.build();
HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
System.out.println(response.statusCode());
String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
String mediaType = contentType.split(";", 2)[0].trim();
if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
System.out.println(new String(response.body(), StandardCharsets.UTF_8));
} else {
Files.write(Path.of("response.bin"), response.body());
System.out.println("Saved " + response.body().length + " bytes to response.bin");
}
}
}go
package main
import (
"fmt"
"io"
"os"
"strings"
"net/http"
"time"
)
const BASE_URL = "https://api.justoneapi.com" // 由 OpenAPI servers 提供
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE"
req, _ := http.NewRequest("GET", url, nil)
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println(resp.StatusCode)
bodyBytes, _ := io.ReadAll(resp.Body)
contentType := strings.ToLower(resp.Header.Get("Content-Type"))
mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
fmt.Println(string(bodyBytes))
} else {
os.WriteFile("response.bin", bodyBytes, 0600)
fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
}
}php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 OpenAPI servers 提供
$url = $BASE_URL . '/api/weibo/get-weibo-detail/v1?token=YOUR_API_KEY&id=VALUE';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
echo $response;
} else {
file_put_contents('response.bin', $response);
echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}返回字段
业务成功时(code = 0)的主要返回字段。
帖子基本信息11 个字段
data.status
所查询的微博帖子。
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 以字符串表示的微博帖子数字 ID。 |
mid | string | 以字符串表示的微博消息 ID。 |
bid | string | 微博帖子的字母数字短 ID。 |
created_at | string | 微博发布时的时间,保留微博原始时间格式。 |
text | string | 微博返回的帖子正文,可能含 HTML 标记。 |
raw_text | string | 微博单独返回时的纯文本正文。 |
textLength | integer | 微博返回的帖子文本长度。 |
source | string | 微博展示的帖子发布来源标签,存在时可用。 |
status_title | string | 微博展示的帖子标题文字。 |
isLongText | boolean | 微博是否将此帖标记为长文。 |
region_name | string | 帖子展示的地区标签。 |
互动数据10 个字段
data.status
| 字段 | 类型 | 说明 |
|---|---|---|
reposts_count | integer | 微博返回的转发数。 |
comments_count | integer | 微博返回的评论数。 |
attitudes_count | integer | 微博返回的表态数。 |
favorites_count | integer | 微博返回的收藏数。 |
pending_approval_count | integer | 待审核评论数。 |
multi_attitude | array | 按表态类型拆分的数据,存在时可用。 |
multi_attitude[] | object | 单种表态的计数条目。 |
multi_attitude[].type | integer | 表态类型的数字代码。 |
multi_attitude[].count | integer | 该类型的表态数量。 |
most_attitude_type | integer | 微博返回的最多表态类型的数字代码。 |
作者20 个字段
data.status.user
帖子附带的公开作者信息。
| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 微博用户的数字 ID。 |
screen_name | string | 微博账号显示名称。 |
description | string | 公开个人简介。 |
profile_image_url | string | 用户资料的头像地址。 |
avatar_hd | string | 高清头像地址。 |
profile_url | string | 微博返回的个人主页链接。 |
cover_image_phone | string | 移动端个人主页封面图片地址。 |
verified | boolean | 微博是否将此账号标记为已认证。 |
verified_type | integer | 微博记录的账号认证数字类型。 |
verified_type_ext | integer | 补充的账号认证数字分类。 |
verified_reason | string | 账号展示的认证说明。 |
statuses_count | integer | 该账号返回的发帖数。 |
follow_count | integer | 微博返回的该账号关注数。 |
followers_count | string | 以文本返回的粉丝数,可能采用缩写格式。 |
followers_count_str | string | 用于展示的粉丝数文本。 |
following | boolean | 当前查看账号是否标记为已关注作者。 |
follow_me | boolean | 作者是否标记为已关注当前查看账号。 |
gender | string | 公开资料记录的性别代码。 |
mbrank | integer | 微博返回的会员等级。 |
urank | integer | 微博返回的账号等级。 |
图片30 个字段
data.status
| 字段 | 类型 | 说明 |
|---|---|---|
pic_num | integer | 此帖返回的图片数量。 |
pic_ids | array | 帖子附带的图片 ID 列表,可能为空。 |
pic_ids[] | string | 微博图片 ID。 |
thumbnail_pic | string | 返回时表示首张图片的缩略图地址。 |
bmiddle_pic | string | 返回时表示首张图片的中等尺寸地址。 |
original_pic | string | 微博原图字段中的地址,存在时可用。 |
pics | array | 微博随帖子返回的图片详情,存在时可用。 |
pics[] | object | 帖子附带的一张图片。 |
pics[].pid | string | 微博图片 ID。 |
pics[].size | string | 该图片版本的尺寸标签。 |
pics[].url | string | 此图片版本的地址。 |
pics[].geo | object | 图片尺寸及裁剪标记。 |
pics[].geo.width | integer | 图片宽度,单位为像素。 |
pics[].geo.height | integer | 图片高度,单位为像素。 |
pics[].geo.croped | boolean | 微博是否将此图标记为已裁剪。 |
pics[].large | object | 较大尺寸的图片版本,存在时可用。 |
pics[].large.url | string | 较大尺寸图片版本的地址。 |
pics[].large.size | string | 该图片版本的尺寸标签。 |
pics[].large.geo | object | 图片尺寸及裁剪标记。 |
pics[].large.geo.width | string | 以文本表示的图片宽度,单位为像素。 |
pics[].large.geo.height | string | 以文本表示的图片高度,单位为像素。 |
pics[].large.geo.croped | boolean | 微博是否将此图标记为已裁剪。 |
pic_focus_point | array | 图片焦点区域列表,存在时可用。 |
pic_focus_point[] | object | 关联一张图片的焦点区域。 |
pic_focus_point[].pic_id | string | 微博图片 ID。 |
pic_focus_point[].focus_point | object | 微博返回的焦点区域坐标与大小。 |
pic_focus_point[].focus_point.left | integer | 焦点区域的左侧坐标。 |
pic_focus_point[].focus_point.top | integer | 焦点区域的顶部坐标。 |
pic_focus_point[].focus_point.width | integer | 焦点区域宽度。 |
pic_focus_point[].focus_point.height | number | 焦点区域高度。 |
内容卡片与视频21 个字段
data.status.page_info
随帖子返回的内容卡片,例如话题或站内视频,存在时可用。
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 微博内容卡片的类型标签。 |
object_type | integer | 微博记录的内容对象数字类型。 |
object_id | string | 内容卡片关联的微博内容对象 ID。 |
page_title | string | 内容卡片展示的标题。 |
title | string | 内容卡片返回的标题字段,可能为空字符串。 |
content1 | string | 内容卡片返回的第一行文字。 |
content2 | string | 内容卡片返回的第二行文字。 |
page_pic | object | 内容卡片的图片信息。 |
page_pic.pid | string | 微博图片 ID。 |
page_pic.url | string | 内容卡片的图片地址。 |
page_pic.width | string | 以文本表示的图片宽度,单位为像素。 |
page_pic.height | string | 以文本表示的图片高度,单位为像素。 |
video_orientation | string | 微博返回的视频画面方向标签。 |
play_count | string | 以展示文本表示的播放量,可能采用缩写格式。 |
media_info | object | 站内视频的播放元数据,存在时可用。 |
media_info.duration | number | 播放元数据返回的视频时长。 |
media_info.stream_url | string | 微博返回的视频流地址。 |
media_info.stream_url_hd | string | 微博返回的高清视频流地址。 |
urls | object | 按格式区分的可用视频地址。 |
urls.mp4_hd_mp4 | string | 高清 MP4 地址,存在时可用。 |
urls.mp4_ld_mp4 | string | 较低清晰度的 MP4 地址,存在时可用。 |
可见性与评论设置13 个字段
data.status
| 字段 | 类型 | 说明 |
|---|---|---|
is_paid | boolean | 微博是否将此帖标记为付费内容。 |
ad_marked | boolean | 微博是否将此帖标记为广告。 |
can_edit | boolean | 当前响应上下文是否可编辑帖子。 |
favorited | boolean | 当前响应上下文是否标记为已收藏此帖。 |
visible | object | 此帖返回的可见性设置。 |
visible.type | integer | 微博返回的可见性数字代码。 |
visible.list_id | integer | 关联可见性名单的数字 ID。 |
comment_manage_info | object | 此帖返回的评论管理设置。 |
comment_manage_info.comment_permission_type | integer | 评论权限的数字设置。 |
comment_manage_info.approval_comment_type | integer | 评论审核的数字设置。 |
comment_manage_info.comment_sort_type | integer | 评论排序的数字设置。 |
comment_manage_info.comment_anon_type | integer | 匿名评论的数字设置。 |
forbid_bullet_screens | boolean | 是否标记为禁用弹幕。 |
转发原帖10 个字段
data.status.retweeted_status
转发时附带的原帖信息,存在时可用。原帖作者信息可能为 null。
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 以字符串表示的微博帖子数字 ID。 |
mid | string | 以字符串表示的微博消息 ID。 |
bid | string | 微博帖子的字母数字短 ID。 |
created_at | string | 微博发布时的时间,保留微博原始时间格式。 |
text | string | 微博返回的帖子正文,可能含 HTML 标记。 |
textLength | integer | 微博返回的帖子文本长度。 |
source | string | 微博展示的帖子发布来源标签,存在时可用。 |
isLongText | boolean | 微博是否将此帖标记为长文。 |
title | object | 此帖附带的标题信息。 |
title.text | string | 展示的标题文字。 |
原帖作者20 个字段
data.status.retweeted_status.user
帖子附带的公开作者信息。
| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 微博用户的数字 ID。 |
screen_name | string | 微博账号显示名称。 |
description | string | 公开个人简介。 |
profile_image_url | string | 用户资料的头像地址。 |
avatar_hd | string | 高清头像地址。 |
profile_url | string | 微博返回的个人主页链接。 |
cover_image_phone | string | 移动端个人主页封面图片地址。 |
verified | boolean | 微博是否将此账号标记为已认证。 |
verified_type | integer | 微博记录的账号认证数字类型。 |
verified_type_ext | integer | 补充的账号认证数字分类。 |
verified_reason | string | 账号展示的认证说明。 |
statuses_count | integer | 该账号返回的发帖数。 |
follow_count | integer | 微博返回的该账号关注数。 |
followers_count | string | 以文本返回的粉丝数,可能采用缩写格式。 |
followers_count_str | string | 用于展示的粉丝数文本。 |
following | boolean | 当前查看账号是否标记为已关注作者。 |
follow_me | boolean | 作者是否标记为已关注当前查看账号。 |
gender | string | 公开资料记录的性别代码。 |
mbrank | integer | 微博返回的会员等级。 |
urank | integer | 微博返回的账号等级。 |
原帖附件与视频24 个字段
data.status.retweeted_status
| 字段 | 类型 | 说明 |
|---|---|---|
pic_num | integer | 此帖返回的图片数量。 |
pic_ids | array | 帖子附带的图片 ID 列表,可能为空。 |
page_info | object | 随帖子返回的内容卡片,例如话题或站内视频,存在时可用。 |
page_info.type | string | 微博内容卡片的类型标签。 |
page_info.object_type | integer | 微博记录的内容对象数字类型。 |
page_info.object_id | string | 内容卡片关联的微博内容对象 ID。 |
page_info.page_title | string | 内容卡片展示的标题。 |
page_info.title | string | 内容卡片返回的标题字段,可能为空字符串。 |
page_info.content1 | string | 内容卡片返回的第一行文字。 |
page_info.content2 | string | 内容卡片返回的第二行文字。 |
page_info.page_pic | object | 内容卡片的图片信息。 |
page_info.page_pic.pid | string | 微博图片 ID。 |
page_info.page_pic.url | string | 内容卡片的图片地址。 |
page_info.page_pic.width | string | 以文本表示的图片宽度,单位为像素。 |
page_info.page_pic.height | string | 以文本表示的图片高度,单位为像素。 |
page_info.video_orientation | string | 微博返回的视频画面方向标签。 |
page_info.play_count | string | 以展示文本表示的播放量,可能采用缩写格式。 |
page_info.media_info | object | 站内视频的播放元数据,存在时可用。 |
page_info.media_info.duration | number | 播放元数据返回的视频时长。 |
page_info.media_info.stream_url | string | 微博返回的视频流地址。 |
page_info.media_info.stream_url_hd | string | 微博返回的高清视频流地址。 |
page_info.urls | object | 按格式区分的可用视频地址。 |
page_info.urls.mp4_hd_mp4 | string | 高清 MP4 地址,存在时可用。 |
page_info.urls.mp4_ld_mp4 | string | 较低清晰度的 MP4 地址,存在时可用。 |
原帖互动与可见性18 个字段
data.status.retweeted_status
| 字段 | 类型 | 说明 |
|---|---|---|
is_paid | boolean | 微博是否将此帖标记为付费内容。 |
ad_marked | boolean | 微博是否将此帖标记为广告。 |
can_edit | boolean | 当前响应上下文是否可编辑帖子。 |
favorited | boolean | 当前响应上下文是否标记为已收藏此帖。 |
visible | object | 此帖返回的可见性设置。 |
visible.type | integer | 微博返回的可见性数字代码。 |
visible.list_id | integer | 关联可见性名单的数字 ID。 |
visible.list_idstr | string | 以文本表示的关联可见性名单 ID。 |
reposts_count | integer | 微博返回的转发数。 |
comments_count | integer | 微博返回的评论数。 |
attitudes_count | integer | 微博返回的表态数。 |
favorites_count | integer | 微博返回的收藏数。 |
pending_approval_count | integer | 待审核评论数。 |
comment_manage_info | object | 此帖返回的评论管理设置。 |
comment_manage_info.comment_permission_type | integer | 评论权限的数字设置。 |
comment_manage_info.approval_comment_type | integer | 评论审核的数字设置。 |
comment_manage_info.comment_sort_type | integer | 评论排序的数字设置。 |
comment_manage_info.comment_anon_type | integer | 匿名评论的数字设置。 |
响应信息1 个字段
data
微博帖子详情。帖子不可用时,此值可能为 null。
| 字段 | 类型 | 说明 |
|---|---|---|
canonical | string | 随帖子返回的规范链接元素,以 HTML 文本表示。 |
响应示例
正在加载响应示例…