頁面:清單

擷取網誌頁面清單。 立即試用查看範例

如果網頁所在的網誌屬於私人網誌,則必須取得授權;如果網頁位於公開網誌,則可以在未經授權的情況下呼叫此方法。

要求

HTTP 要求

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

參數

參數名稱 價值 說明
必要參數
blogId string 要擷取網頁的網誌 ID。
選用參數
fetchBodies boolean 是否擷取頁面內文。
status string

可接受的值為:
  • draft」:草稿 (未發布) 頁面
  • imported」:網頁的內容遭到移除
  • live」:公開顯示的網頁
view string

可接受的值為:
  • ADMIN」:管理員層級詳細資料
  • AUTHOR」:作者層級詳細資料
  • READER」:管理員層級詳細資料

要求主體

請勿使用這個方法提供請求主體。

回覆

如果成功的話,這個方法會傳回回應內文,其結構如下:

{
  "kind": "blogger#pageList",
  "items": [
    pages Resource
  ]
}
屬性名稱 價值 說明 附註
kind string 這個實體的種類。一律為 blogger#pageList
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-PagesList-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
List pagesListAction = blogger.pages().list(BUZZ_BLOG_ID);
// Restrict the result content to just the data we need.
pagesListAction.setFields("items(content,title,updated,url)");
// This step sends the request to the server.
PageList pages = pagesListAction.execute();
// Now we can navigate the response.
if (pages.getItems() != null && !pages.getItems().isEmpty()) {
for (Page page : pages.getItems()) {
System.out.println("Title: " + page.getTitle());
System.out.println("URL: " + page.getUrl());
System.out.println("Last Updated:" + page.getUpdated());
System.out.println("Content: " + page.getContent());
}
}

試試看!

您可以使用下方的 API Explorer,針對即時資料呼叫這個方法,然後查看回應。