跳至主要內容

微博帖子評論 API (V1) ​

GET
API 端點健康狀態
健康 可用 少量可用 基本不可用 暫無資料
正在載入健康狀態…

檢索由MID標識的微博帖子的評論,支持可選的maxId游標分頁以及時間或熱度排序。用於查看受衆討論、繼續翻閱評論區或支持審覈和反饋分析。

請求參數 ​

參數名 位置 類型 必填 預設值 說明
token query string 是 - API 訪問令牌。
mid query string 是 - 微博帖子 mid。
sort query string 否 TIME 結果集的排序順序。


可用值:

- TIME: 時間

- HOT: 熱門
maxId query string 否 - 由先前回應返回的分頁游標。

程式碼範例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/weibo/get-post-comments/v1?token=YOUR_API_KEY&mid=VALUE'
text
我想使用 JustOneAPI 提供的“帖子評論 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/weibo/get-post-comments/v1?token=YOUR_API_KEY&mid=VALUE
接口地址: BASE_URL + /api/weibo/get-post-comments/v1?token=YOUR_API_KEY&mid=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/weibo/post-comments-v1-zh-hant.json

請求參數說明:
- token (query): API 訪問令牌。 (必填)
- mid (query): 微博帖子 mid。 (必填)
- sort (query): 結果集的排序順序。

可用值:
- `TIME`: 時間
- `HOT`: 熱門
- maxId (query): 由先前回應返回的分頁游標。

返回格式: 請根據實際 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-post-comments/v1?token=YOUR_API_KEY&mid=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-post-comments/v1?token=YOUR_API_KEY&mid=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-post-comments/v1?token=YOUR_API_KEY&mid=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-post-comments/v1?token=YOUR_API_KEY&mid=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-post-comments/v1?token=YOUR_API_KEY&mid=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)的主要返回欄位。

分頁與篩選12 個欄位

data

請求頁的微博評論、預覽回覆和分頁信息。

欄位 類型 說明
ok integer 微博評論資料對象內部的狀態標記。
total_number integer 博文返回的評論總數。當前頁的評論條數可以少於這個值。
max_id integer 博文評論續頁游標。同一博文和排序方式下,把完整的十進制文本傳給 maxId。0 表示沒有下一頁游標。空結果可能省略該欄位。
data array 請求頁的一級評論,數組可能為空。
data[] object 請求的微博博文下的一條一級評論。
rootComment array 回應附帶的根評論數組。已覈對的樣本中該數組為空。
tip_msg string 評論列表的展示提示,可能為空字符串。
trendsText string 評論列表返回的趨勢相關展示文本。
filter_group array 評論列表返回的篩選選項。
filter_group[] object 評論列表的一項篩選選項。
filter_group[].title string 篩選選項的展示標題。
filter_group[].isDefault integer 該篩選項是否為預設項的數字標記。
一級評論15 個欄位

data.data[]

欄位 類型 說明
id integer 評論 ID,以整數返回。需要保留完整數字時可用 idstr。
idstr string 評論 ID 的字符串形式。
mid string 評論自身的 MID,以字符串返回。請求參數 mid 標識的是博文。
rootid integer 該評論線程的根評論 ID,以整數返回。
rootidstr string 根評論 ID 的字符串形式。
floor_number integer 線程內返回的評論樓層號。
created_at string 評論發佈時間,以平台格式的文本返回。
text string 用於展示的評論內容,可能包含 HTML。
text_raw string 與展示內容分開返回的原始評論文本。
source string 評論展示的來源標籤。
source_allowclick integer 來源標籤能否點擊的平台數字標記。
source_type integer 評論來源標籤的類型代碼。
disable_reply integer 平台標記評論是否關閉回覆的數字值。
like_counts integer like_counts 欄位返回的點贊數量。
isLikedByMblogAuthor boolean 博文作者是否點贊該評論,有資料時返回。
一級評論作者45 個欄位

data.data[]

欄位 類型 說明
user object 評論作者的公開主頁信息。
user.id integer 微博用戶的數字 ID。
user.idstr string 微博用戶 ID 的字符串形式。
user.screen_name string 微博用戶的展示暱稱。
user.profile_image_url string 用戶頭像圖片連結。
user.avatar_large string 大尺寸頭像連結。
user.avatar_hd string 高清頭像連結。
user.cover_image_phone string 移動端用戶主頁的封面圖片連結。
user.profile_url string 微博公開用戶主頁的路徑或連結。
user.domain string 用戶主頁的自定義地址片段,有資料時提供。
user.weihao string 微博主頁微號,可能為空字符串。
user.url string 用戶公開主頁上填寫的網站連結,可能為空字符串。
user.description string 用戶主頁展示的簡介。
user.location string 公開用戶主頁展示的地區。
user.gender string 公開用戶主頁返回的性別代碼。
user.verified boolean 該用戶資料是否帶有認證標記。
user.verified_type integer 用戶主頁返回的認證類型代碼。
user.verified_type_ext integer 額外的認證類型代碼,有資料時返回。
user.verified_reason string 用戶主頁展示的認證說明,有資料時返回。
user.followers_count integer 用戶主頁返回的粉絲數。
user.followers_count_str string 粉絲數量的展示文本。
user.friends_count integer 該用戶關注的帳號數量。
user.statuses_count integer 用戶主頁返回的發博數量。
user.status_total_counter object 用戶主頁返回的博文互動計數。
user.status_total_counter.total_cnt_format string | integer 格式化的互動總數,以文本或整數返回。
user.status_total_counter.comment_cnt string 主頁計數中的評論數,以文本返回。
user.status_total_counter.repost_cnt string 主頁計數中的轉發數,以文本返回。
user.status_total_counter.like_cnt string 主頁計數中的點贊數,以文本返回。
user.status_total_counter.total_cnt string 主頁計數中的總數,以文本返回。
user.mbrank integer 用戶主頁返回的微博會員等級。
user.mbtype integer 用戶主頁的平台會員類型代碼。
user.svip integer 用戶主頁返回的 SVIP 數字標記。
user.vvip integer 用戶主頁返回的 VVIP 數字標記。
user.icon_list array 用戶主頁展示的圖標或標記。
user.icon_list[] object 一項用戶主頁標記或圖標。
user.icon_list[].type string 主頁圖標返回的類型標籤。
user.icon_list[].data object 主頁圖標的展示和會員信息。
user.icon_list[].data.mbrank integer 圖標對應的會員等級。
user.icon_list[].data.mbtype integer 圖標對應的平台會員類型代碼。
user.icon_list[].data.svip integer 圖標信息中的 SVIP 數字標記。
user.icon_list[].data.vvip integer 圖標信息中的 VVIP 數字標記。
user.icon_list[].data.value string 該主頁圖標返回的文本值。
user.icon_list[].data.icon_img string 主頁圖標的圖片連結。
user.icon_list[].data.title string 主頁圖標的展示標題。
user.icon_list[].data.url string 主頁圖標關聯的連結。
話題、連結與展示33 個欄位

data.data[]

欄位 類型 說明
url_objects array 評論附帶的額外連結條目,數組可能為空。
pic_num integer 評論返回的圖片數量。
topic_struct array 評論附帶的話題標籤和連結。
topic_struct[] object 評論中的一條話題。
topic_struct[].title string 話題條目的展示標題。
topic_struct[].topic_title string 話題返回的標題文本。
topic_struct[].topic_url string 話題關聯的連結。
url_struct array 評論附帶的結構化連結信息。
url_struct[] object 評論中的一條連結。
url_struct[].url_title string 連結的展示標題。
url_struct[].url_type_pic string 該連結類型對應的圖標圖片連結。
url_struct[].ori_url string 該條目返回的原始連結。
url_struct[].short_url string 該條目返回的短連結。
url_struct[].long_url string 該條目返回的長連結。
url_struct[].h5_target_url string 該條目返回的網頁目標連結。
url_struct[].page_id string 連結關聯的頁面標識。
url_struct[].url_type string 連結類型代碼,以字符串返回。
url_struct[].object_type string 連結所指對象的類型標籤。
comment_bubble object 評論氣泡的裝飾展示信息。
comment_bubble.id string 評論氣泡裝飾標識。
comment_bubble.name string 評論氣泡裝飾的展示名稱。
comment_bubble.start_color string 評論氣泡返回的起始顏色。
comment_bubble.end_color string 評論氣泡返回的結束顏色。
comment_bubble.start_color_dark string 深色模式下評論氣泡的起始顏色。
comment_bubble.end_color_dark string 深色模式下評論氣泡的結束顏色。
comment_bubble.icon_url string 氣泡裝飾圖標的圖片連結。
comment_bubble.tag_text string 氣泡裝飾對應的展示標籤。
hot_icon object 評論熱度標記的展示信息。
hot_icon.url string 熱度標記的圖片連結。
hot_icon.wh_ratio string 熱度標記圖片的寬高比,以文本返回。
more_info object 評論附帶的更多信息展示文本。
more_info.text string 更多信息的展示文本。
more_info.highlight_text string 更多信息展示文本的高亮部分。
預覽回覆與計數4 個欄位

data.data[]

欄位 類型 說明
comments array 該評論附帶的預覽回覆。還可能有未包含在預覽中的回覆。
comments[] object 一級評論附帶的一條預覽回覆。
total_number integer 該評論返回的回覆總數。
max_id integer 該評論預覽回覆附帶的游標。博文評論列表使用回應對象最外層的 max_id。
預覽回覆內容24 個欄位

data.data[].comments[]

欄位 類型 說明
id integer 評論 ID,以整數返回。需要保留完整數字時可用 idstr。
idstr string 評論 ID 的字符串形式。
mid string 評論自身的 MID,以字符串返回。請求參數 mid 標識的是博文。
rootid integer 該評論線程的根評論 ID,以整數返回。
rootidstr string 根評論 ID 的字符串形式。
floor_number integer 線程內返回的評論樓層號。
created_at string 評論發佈時間,以平台格式的文本返回。
text string 用於展示的評論內容,可能包含 HTML。
text_raw string 與展示內容分開返回的原始評論文本。
source string 評論展示的來源標籤。
source_allowclick integer 來源標籤能否點擊的平台數字標記。
source_type integer 評論來源標籤的類型代碼。
disable_reply integer 平台標記評論是否關閉回覆的數字值。
like_counts integer like_counts 欄位返回的點贊數量。
url_objects array 評論附帶的額外連結條目,數組可能為空。
pic_num integer 評論返回的圖片數量。
reply_comment object 預覽回覆所回應的原評論對象。
like_count integer 該回復的 like_count 欄位返回的點贊數量。
is_mblog_author boolean 回覆作者是否為博文作者。
is_sub_cmt boolean 平台是否將該條目標記為子評論。
blogger_icons array 預覽回覆作者附帶的標記。
blogger_icons[] object 一個作者展示標記。
blogger_icons[].name string 作者標記的展示名稱。
blogger_icons[].url string 作者標記關聯的連結。
預覽回覆作者41 個欄位

data.data[].comments[]

欄位 類型 說明
user object 預覽回覆作者的公開主頁信息。
user.id integer 微博用戶的數字 ID。
user.idstr string 微博用戶 ID 的字符串形式。
user.screen_name string 微博用戶的展示暱稱。
user.profile_image_url string 用戶頭像圖片連結。
user.avatar_large string 大尺寸頭像連結。
user.avatar_hd string 高清頭像連結。
user.cover_image_phone string 移動端用戶主頁的封面圖片連結。
user.profile_url string 微博公開用戶主頁的路徑或連結。
user.domain string 用戶主頁的自定義地址片段,有資料時提供。
user.weihao string 微博主頁微號,可能為空字符串。
user.url string 用戶公開主頁上填寫的網站連結,可能為空字符串。
user.description string 用戶主頁展示的簡介。
user.location string 公開用戶主頁展示的地區。
user.gender string 公開用戶主頁返回的性別代碼。
user.verified boolean 該用戶資料是否帶有認證標記。
user.verified_type integer 用戶主頁返回的認證類型代碼。
user.verified_type_ext integer 額外的認證類型代碼,有資料時返回。
user.verified_reason string 用戶主頁展示的認證說明,有資料時返回。
user.followers_count integer 用戶主頁返回的粉絲數。
user.followers_count_str string 粉絲數量的展示文本。
user.friends_count integer 該用戶關注的帳號數量。
user.statuses_count integer 用戶主頁返回的發博數量。
user.status_total_counter object 用戶主頁返回的博文互動計數。
user.status_total_counter.total_cnt_format string | integer 格式化的互動總數,以文本或整數返回。
user.status_total_counter.comment_cnt string 主頁計數中的評論數,以文本返回。
user.status_total_counter.repost_cnt string 主頁計數中的轉發數,以文本返回。
user.status_total_counter.like_cnt string 主頁計數中的點贊數,以文本返回。
user.status_total_counter.total_cnt string 主頁計數中的總數,以文本返回。
user.mbrank integer 用戶主頁返回的微博會員等級。
user.mbtype integer 用戶主頁的平台會員類型代碼。
user.svip integer 用戶主頁返回的 SVIP 數字標記。
user.vvip integer 用戶主頁返回的 VVIP 數字標記。
user.icon_list array 用戶主頁展示的圖標或標記。
user.icon_list[] object 一項用戶主頁標記或圖標。
user.icon_list[].type string 主頁圖標返回的類型標籤。
user.icon_list[].data object 主頁圖標的展示和會員信息。
user.icon_list[].data.mbrank integer 圖標對應的會員等級。
user.icon_list[].data.mbtype integer 圖標對應的平台會員類型代碼。
user.icon_list[].data.svip integer 圖標信息中的 SVIP 數字標記。
user.icon_list[].data.vvip integer 圖標信息中的 VVIP 數字標記。
被回覆的評論11 個欄位

data.data[].comments[].reply_comment

欄位 類型 說明
id integer 評論 ID,以整數返回。需要保留完整數字時可用 idstr。
idstr string 評論 ID 的字符串形式。
mid string 評論自身的 MID,以字符串返回。請求參數 mid 標識的是博文。
rootid integer 該評論線程的根評論 ID,以整數返回。
rootidstr string 根評論 ID 的字符串形式。
floor_number integer 線程內返回的評論樓層號。
created_at string 評論發佈時間,以平台格式的文本返回。
text string 用於展示的評論內容,可能包含 HTML。
disable_reply integer 平台標記評論是否關閉回覆的數字值。
url_objects array 評論附帶的額外連結條目,數組可能為空。
pic_num integer 評論返回的圖片數量。
被回覆評論的作者45 個欄位

data.data[].comments[].reply_comment

欄位 類型 說明
user object 被回覆評論作者的公開主頁信息。
user.id integer 微博用戶的數字 ID。
user.idstr string 微博用戶 ID 的字符串形式。
user.screen_name string 微博用戶的展示暱稱。
user.profile_image_url string 用戶頭像圖片連結。
user.avatar_large string 大尺寸頭像連結。
user.avatar_hd string 高清頭像連結。
user.cover_image_phone string 移動端用戶主頁的封面圖片連結。
user.profile_url string 微博公開用戶主頁的路徑或連結。
user.domain string 用戶主頁的自定義地址片段,有資料時提供。
user.weihao string 微博主頁微號,可能為空字符串。
user.url string 用戶公開主頁上填寫的網站連結,可能為空字符串。
user.description string 用戶主頁展示的簡介。
user.location string 公開用戶主頁展示的地區。
user.gender string 公開用戶主頁返回的性別代碼。
user.verified boolean 該用戶資料是否帶有認證標記。
user.verified_type integer 用戶主頁返回的認證類型代碼。
user.verified_type_ext integer 額外的認證類型代碼,有資料時返回。
user.verified_reason string 用戶主頁展示的認證說明,有資料時返回。
user.followers_count integer 用戶主頁返回的粉絲數。
user.followers_count_str string 粉絲數量的展示文本。
user.friends_count integer 該用戶關注的帳號數量。
user.statuses_count integer 用戶主頁返回的發博數量。
user.status_total_counter object 用戶主頁返回的博文互動計數。
user.status_total_counter.total_cnt_format string | integer 格式化的互動總數,以文本或整數返回。
user.status_total_counter.comment_cnt string 主頁計數中的評論數,以文本返回。
user.status_total_counter.repost_cnt string 主頁計數中的轉發數,以文本返回。
user.status_total_counter.like_cnt string 主頁計數中的點贊數,以文本返回。
user.status_total_counter.total_cnt string 主頁計數中的總數,以文本返回。
user.mbrank integer 用戶主頁返回的微博會員等級。
user.mbtype integer 用戶主頁的平台會員類型代碼。
user.svip integer 用戶主頁返回的 SVIP 數字標記。
user.vvip integer 用戶主頁返回的 VVIP 數字標記。
user.icon_list array 用戶主頁展示的圖標或標記。
user.icon_list[] object 一項用戶主頁標記或圖標。
user.icon_list[].type string 主頁圖標返回的類型標籤。
user.icon_list[].data object 主頁圖標的展示和會員信息。
user.icon_list[].data.mbrank integer 圖標對應的會員等級。
user.icon_list[].data.mbtype integer 圖標對應的平台會員類型代碼。
user.icon_list[].data.svip integer 圖標信息中的 SVIP 數字標記。
user.icon_list[].data.vvip integer 圖標信息中的 VVIP 數字標記。
user.icon_list[].data.value string 該主頁圖標返回的文本值。
user.icon_list[].data.icon_img string 主頁圖標的圖片連結。
user.icon_list[].data.title string 主頁圖標的展示標題。
user.icon_list[].data.url string 主頁圖標關聯的連結。

回應示例 ​

正在載入回應範例…