網誌:listByUser

需要授權

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

要求

HTTP 要求

GET https://www.googleapis.com/blogger/v3/users/userId/blogs

參數

參數名稱 說明
必要參數
userId string 要擷取網誌的使用者 ID。self 或使用者的設定檔 ID。
選用參數
fetchUserInfo boolean 該回應是否為包含個別使用者資訊的網誌清單,而非只列出網誌。
view string

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

授權

此要求需要至少具備下列其中一個範圍的授權 (進一步瞭解驗證和授權)。

範圍
https://www.googleapis.com/auth/blogger
https://www.googleapis.com/auth/blogger.readonly

要求主體

請不要透過此方法提供請求主體。

回應

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

{
  "kind": "blogger#blogList",
  "items": [
    blogs Resource
  ],
  "blogUserInfos": [
    blogUserInfos Resource
  ]
}
屬性名稱 說明 Notes
kind string 這個實體的種類。一律為 blogger#blogList
items[] list 這位使用者擁有授權或管理員權限的網誌清單。
blogUserInfos[] list 每位使用者資訊的網誌層級管理員清單

範例

注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面

Java

使用 Java 用戶端程式庫

// 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-BlogListByUser-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action object.
ListByUser blogListByUserAction = blogger.blogs().listByUser("self");
// Restrict the result content to just the data we need.
blogListByUserAction.setFields("items(description,name,posts/totalItems,updated)");
// This step sends the request to the server.
BlogList blogList = blogListByUserAction.execute();
// Now we can navigate the response.
if (blogList.getItems() != null && !blogList.getItems().isEmpty()) {
int blogCount = 0;
for (Blog blog : blogList.getItems()) {
System.out.println("Blog #" + ++blogCount);
System.out.println("\tName: " + blog.getName());
System.out.println("\tDescription: " + blog.getDescription());
System.out.println("\tPost Count: " + blog.getPosts().getTotalItems());
System.out.println("\tLast Updated: " + blog.getUpdated());
}
}

試試看!

使用 APIs Explorer 針對即時資料呼叫這個方法,並查看回應。