WeChat公式アカウント アカウントの過去記事 API (V1)
APIの健康状態
正常 利用可能 限られた数 ほとんど利用できない データなし
健康状態を読み込んでいます...
ユーザー名でWeChat公式アカウントの歴史的投稿を取得します。カーソルによる分页機能や記事、ビデオ、オーディオ、画像コンテンツのタブを使用できます。アカウントの公開履歴を閲覧するために使用します。
リクエストボディ
| 名前 | パラメーターの場所 | タイプ | 必須 | デフォルト | 説明 |
|---|---|---|---|---|---|
token |
form | string |
はい | - | このAPIサービスのアクセストークン。 |
username |
form | string |
はい | - | gh_プレフィックスを使用したWeChat公式アカウントのユーザー名。 |
offset |
form | string |
いいえ | |
Base64エンコードされたページングカーソル。最初のページの場合は空欄にして、前のレスポンスからnext_offsetを渡して次のページを指定する。URLエンコードされた形式で送信する。 |
itemShowType |
form | string |
いいえ | ARTICLE |
コンテンツタブ。デフォルトはARTICLEです。 利用可能な値: - ARTICLE: 記事- VIDEO: ビデオ- AUDIO: オーディオ- IMAGE: 画像 |
コードサンプル
bash
curl --max-time 120 -X POST 'https://api.justoneapi.com/api/weixin/get-account-history-articles/v1' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'token=YOUR_API_KEY&username=string&offset=&itemShowType=ARTICLE'
text
私はJustOneAPIの"アカウントの過去記事 (V1)" APIを使用したいです。
基本URL: https://api.justoneapi.com.
APIパス: /api/weixin/get-account-history-articles/v1
APIエンドポイント: BASE_URL + /api/weixin/get-account-history-articles/v1
HTTPメソッド: POST
認証: "token"をapplication/x-www-form-urlencodedボディフィールドとして送信します。
OpenAPI定義: https://docs.justoneapi.com/openapi/wechat-official-accounts/account-historical-articles-v1-ja.json
リクエストヘッダー:
- Content-Type: application/x-www-form-urlencoded
リクエストボディ(フォーム):
- token (form): このAPIサービスのアクセストークン。 (必須)
- username (form): gh_プレフィックスを使用したWeChat公式アカウントのユーザー名。 (必須)
- offset (form): Base64エンコードされたページングカーソル。最初のページの場合は空欄にして、前のレスポンスからnext_offsetを渡して次のページを指定する。URLエンコードされた形式で送信する。
- itemShowType (form): コンテンツタブ。デフォルトはARTICLEです。
利用可能な値:
- `ARTICLE`: 記事
- `VIDEO`: ビデオ
- `AUDIO`: オーディオ
- `IMAGE`: 画像
返信形式:実際のContent-Typeに応じて、JSONまたはテキストを安全に処理する。
レスポンスの処理とエラーコード:
1. API の処理結果はレスポンス本文の「code」フィールドで判定します。code が 0 なら成功です。
2. 推奨タイムアウト:リクエストのタイムアウトは 120 秒に設定してください。120 秒が長すぎる場合でも、最低 60 秒を確保してください。一部のリクエストは、結果を受け取る前にタイムアウトすることがあります。
3. 処理結果コード:
- 0: 成功
- 100: 無効または停止中のトークン
- 301: データの取得に失敗しました。再試行してください。
- 302: 呼び出し頻度の上限を超えました
- 303: 日次の利用上限を超えました
- 400: パラメーターが無効です
- 500: サーバー内部エラー
- 600: アクセス権限がありません
- 601: 残高不足
- 602: トークンの予算上限に達しました
4. コード 601 はアカウントの共有残高不足を示します。コード 602 は使用中の API トークン固有の累積予算上限に達したことを示します。トークンに予算上限を設定しても、共有残高から資金が移動することはありません。
お手伝いください。私が好むプログラミング言語でこのAPIを呼び出し、レスポンスを処理するスクリプトを作成してください。
python
import requests
BASE_URL = "https://api.justoneapi.com" # オープンAPIサーバーによって提供される
url = BASE_URL + "/api/weixin/get-account-history-articles/v1"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = "token=YOUR_API_KEY&username=string&offset=&itemShowType=ARTICLE"
response = requests.post(url, headers=headers, data=data, 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"; // オープンAPIサーバーによって提供される
const url = BASE_URL + "/api/weixin/get-account-history-articles/v1";
const response = await fetch(url, {
method: "POST",
headers: Object.fromEntries([
["Content-Type", "application/x-www-form-urlencoded"],
]),
body: "token=YOUR_API_KEY&username=string&offset=&itemShowType=ARTICLE",
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"; // オープンAPIサーバーによって提供される
final String url = BASE_URL + "/api/weixin/get-account-history-articles/v1";
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(120))
.header("Content-Type", "application/x-www-form-urlencoded")
.method("POST", HttpRequest.BodyPublishers.ofString("token=YOUR_API_KEY&username=string&offset=&itemShowType=ARTICLE"));
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" // オープンAPIサーバーによって提供される
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/weixin/get-account-history-articles/v1"
var data = strings.NewReader("token=YOUR_API_KEY&username=string&offset=&itemShowType=ARTICLE")
req, _ := http.NewRequest("POST", url, data)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
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'; // オープンAPIサーバーによって提供される
$url = $BASE_URL . '/api/weixin/get-account-history-articles/v1';
$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, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, 'token=YOUR_API_KEY&username=string&offset=&itemShowType=ARTICLE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
]);
$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)。
ページと続き6 項目
data
選択されたコンテンツタブのWeChat公式アカウントの履歴記録と続き情報。
| フィールド | タイプ | 説明 |
|---|---|---|
biz_username |
string |
履歴ページに返される公式アカウントのユーザー名、gh_プレフィックス付き。 |
count |
integer |
この応答で返される履歴記録の数。 |
pages |
integer |
この応答で返されるプラットフォームページ数。 |
is_end |
integer | null |
リスト終了フラグが報告された。カーソルでチェックされたページは0を、最後は1を返す。空の結果はnullを返すことがある。 |
next_offset |
string | null |
次のページの続き値。空でない値をオフセットフォームフィールドとして変更なく渡す。nullの値も許容される。 |
articles |
array |
選択されたコンテンツタブの履歴記録。空のリストが返されることがある。 |
メッセージグループ10 項目
data.articles[]
| フィールド | タイプ | 説明 |
|---|---|---|
baseInfo |
object |
履歴記録に付随するプラットフォームメッセージ情報。 |
baseInfo.msgId |
integer |
履歴レコードのメッセージ ID。動画レコードではゼロの場合があります。 |
baseInfo.msgType |
integer |
履歴記録のプラットフォームメッセージタイプコード。 |
baseInfo.dateTime |
integer |
メッセージのタイムスタンプ(Unix秒)。ビデオ記録の場合はゼロが可能。 |
appMsg |
object |
メッセージグループとその個別のコンテンツアイテム。 |
appMsg.baseInfo |
object |
グループ化されたメッセージの基本情報。 |
appMsg.baseInfo.appMsgId |
integer |
グループ化されたコンテンツに対して返されるWeChatメッセージID。 |
appMsg.baseInfo.type |
integer |
グループ化されたメッセージのプラットフォームタイプコード。 |
appMsg.baseInfo.createTime |
integer |
グループ化されたメッセージの作成時刻(Unix秒)。 |
appMsg.baseInfo.updateTime |
integer |
グループ化されたメッセージの更新時刻(Unix秒)。 |
コンテンツ項目14 項目
data.articles[].appMsg.detailInfo[]
メッセージグループ内の個別のコンテンツアイテム。
| フィールド | タイプ | 説明 |
|---|---|---|
title |
string |
コンテンツアイテムに表示されるタイトル。 |
showDesc |
string |
コンテンツアイテムと共に表示される説明テキスト。 |
shortShowDesc |
string |
提供されている場合のコンテンツアイテムの短い表示説明。 |
digest |
string |
コンテンツアイテムに対して返されるダイジェスト。空でも可。 |
authorDesc |
string |
コンテンツアイテムに対して返される著者説明テキスト。空でも可。 |
contentUrl |
string |
アイテムに対して返されるコンテンツリンク。 |
sourceUrl |
string |
このアイテムに関連するソースリンク(利用可能な場合)。 |
sendTime |
integer |
コンテンツアイテムの送信時刻(Unix秒)、提供されている場合。 |
itemIndex |
integer |
コンテンツアイテムが属するメッセージグループ内の位置。 |
itemShowType |
integer |
このコンテンツアイテムに対して返されるプラットフォーム表示タイプコード。 |
isModified |
integer |
コンテンツアイテムに対して報告される変更指示。 |
isPaid |
integer |
コンテンツアイテムに対して報告される有料コンテンツ指示。 |
isPaySubscribe |
integer |
コンテンツアイテムに対して報告される有料サブスクリプション指示。 |
picCount |
integer |
コンテンツアイテムに対して報告される画像数。 |
カバーと動画12 項目
data.articles[].appMsg.detailInfo[]
| フィールド | タイプ | 説明 |
|---|---|---|
coverImgUrl |
string |
このアイテムに対して返される主要なカバー画像URL。 |
coverImgUrl11 |
string |
バリアント11に対して返されるカバー画像URL。 |
coverImgUrl169 |
string |
バリアント169のカバー画像URLが返されました。 |
coverImgUrl169640 |
string |
バリアント169640のカバー画像URLが返されました。 |
coverImgUrl2351 |
string |
バリアント2351のカバー画像URLが返されました。 |
coverimgurl34 |
string |
バリアント34のカバー画像URLが返されました。 |
preloadPictureInfo |
object | null |
利用可能な場合はプリロード用の画像が提供されました。nullの場合もあります。 |
preloadPictureInfo.cdnUrl |
string |
プリロード用の画像のURLです。 |
videoId |
string |
このコンテンツ項目に対して返されるビデオ識別子です。空の場合もあります。 |
videoDuration |
integer |
報告されたビデオの持続時間値です。時間単位は確認されていません。 |
videoWidth |
integer |
項目について報告された動画フレームの幅。ゼロの場合があります。 |
videoHeight |
integer |
項目について報告された動画フレームの高さ。ゼロの場合があります。 |
エンゲージメント数2 項目
data.articles[].appMsg.detailInfo[].statInfo
コンテンツ項目に対して提供されたエンゲージメントカウンターです。
| フィールド | タイプ | 説明 |
|---|---|---|
likeNum |
integer |
コンテンツ項目のいいね数(報告値)。 |
readNum |
integer |
コンテンツ項目に対して報告された読了数です。 |
レスポンス例
レスポンスのサンプルを読み込んでいます...