非公開ブログに投稿する場合は承認が必要です。一般公開されているブログの投稿の場合は、このメソッドを許可なく呼び出すことができます。
リクエスト
HTTP リクエスト
GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts
パラメータ
パラメータ名 | 値 | 説明 |
---|---|---|
必須パラメータ | ||
blogId |
string |
投稿を取得するブログの ID。 |
オプション パラメータ | ||
endDate |
datetime |
取得する最新の投稿の日付(RFC 3339 形式の date-time )。
|
fetchBodies |
boolean |
投稿の本文コンテンツを含めるかどうかを指定します(デフォルト: true)。トラフィックを最小限に抑えるために、投稿の本文が不要な場合は false に設定してください。(デフォルト: true )。 |
fetchImages |
boolean |
各投稿の画像の URL メタデータを含めるかどうか。 |
labels |
string |
検索するラベルのカンマ区切りのリスト。 |
maxResults |
unsigned integer |
取得する投稿の最大数。 |
orderBy |
string |
並べ替え順序を結果に適用しました。
有効な値は次のとおりです。
|
sortOption |
string |
UNAVAILABLE NOW
結果に適用される並べ替えの方向。 有効な値は次のとおりです。
|
pageToken |
string |
継続トークン(リクエストがページングされている場合)。 |
startDate |
datetime |
取得する投稿の最も早い投稿日。RFC 3339 形式で date-time なります。
|
status |
string |
有効な値は次のとおりです。
|
view |
string |
有効な値は次のとおりです。
|
リクエスト本文
このメソッドをリクエストの本文に含めないでください。
レスポンス
成功すると、このメソッドは次の構造を含むレスポンスの本文を返します。
{ "kind": "blogger#postList", "nextPageToken": string, "items": [ posts Resource ] }
プロパティ名 | 値 | 説明 | 備考 |
---|---|---|---|
kind |
string |
このエンティティの種類です。常に blogger#postList です。 |
|
nextPageToken |
string |
次のページを取得するためのページ設定トークン(存在する場合)。 | |
items[] |
list |
このブログの投稿のリスト。 |
例
注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します
// The BlogId for the Blogger Buzz blog String BUZZ_BLOG_ID = "2399953";
// Configure the Java API Client for Installed Native App
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
// Configure the Installed App OAuth2 flow.
Credential credential = OAuth2Native.authorize(HTTP_TRANSPORT,
JSON_FACTORY, new LocalServerReceiver(),
Arrays.asList(BloggerScopes.BLOGGER));
// Construct the Blogger API access facade object.
Blogger blogger = Blogger.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Blogger-PostsList-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
List postsListAction = blogger.posts().list(BUZZ_BLOG_ID);
// Restrict the result content to just the data we need.
postsListAction.setFields("items(author/displayName,content,published,title,url),nextPageToken");
// This step sends the request to the server.
PostList posts = postsListAction.execute();
// Now we can navigate the response.
int postCount = 0;
int pageCount = 0;
while (posts.getItems() != null && !posts.getItems().isEmpty()) {
for (Post post : posts.getItems()) {
System.out.println("Post #"+ ++postCount);
System.out.println("\tTitle: "+post.getTitle());
System.out.println("\tAuthor: "+post.getAuthor().getDisplayName());
System.out.println("\tPublished: "+post.getPublished());
System.out.println("\tURL: "+post.getUrl());
System.out.println("\tContent: "+post.getContent());
}
// Pagination logic
String pageToken = posts.getNextPageToken();
if (pageToken == null || ++pageCount >= 5) {
break;
}
System.out.println("-- Next page of posts");
postsListAction.setPageToken(pageToken);
posts = postsListAction.execute();
}
実習
以下の API Explorer を使用して、ライブデータでこのメソッドを呼び出し、レスポンスを確認します。