投稿: 検索

指定したクエリ語句に一致する投稿を検索します。 今すぐ試すまたは例を見る

検索対象のブログが非公開の場合は、承認が必要になります。

リクエスト

HTTP リクエスト

GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/search

パラメータ

パラメータ名 説明
必須パラメータ
blogId string 検索するブログの ID。
q string 検索するクエリ語句。
オプション パラメータ
fetchBodies boolean 投稿の本文コンテンツを含めるかどうか。トラフィックを最小限に抑えるには、投稿の本文が不要な場合に、このパラメータを false に設定します。 (デフォルト: true)。
orderBy string 検索結果に適用される並べ替え順。

有効な値は次のとおりです。
  • published」: 投稿が公開された日付の順に表示します
  • updated」: 投稿の最終更新日順に並べ替えます

リクエスト本文

このメソッドをリクエストの本文に含めないでください。

レスポンス

成功すると、このメソッドは次の構造を含むレスポンスの本文を返します。

{
 
"kind": "blogger#postList",
 
"nextPageToken": string,
 
"items": [
   
posts Resource
 
]
}
プロパティ名 説明 メモ
kind string このエンティティの種類。常に blogger#postList
nextPageToken string 次のページを取得するためのページネーション トークン(存在する場合)。
items[] list このブログの投稿のリスト。

注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。

Java

Java クライアント ライブラリを使用します

// The BlogId for the http://buzz.blogger.com/ 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-PostsSearch-Snippet/1.0")
        .setHttpRequestInitializer(credential).build();

// The request action.
Search postsSearchAction = blogger.posts().search(BUZZ_BLOG_ID);
postsSearchAction
.setQ("threaded comments");

// Restrict the result content to just the data we need.
postsSearchAction.setFields("items(content,published,title,url)");

// This step sends the request to the server.
PostList posts = postsSearchAction.execute();

// Now we can navigate the response.
if (posts.getItems() != null && !posts.getItems().isEmpty()) {
        for (Post post : posts.getItems()) {
                System.out.println("Title: " + post.getTitle());
                System.out.println("Published: " + post.getPublished());
                System.out.println("URL: " + post.getUrl());
                System.out.println("Content: " + post.getContent());
        }
}