網誌:get

依 ID 擷取網誌。立即試用查看範例

如果網誌是私人的,就必須提供授權。如果該網誌設為公開,不必取得授權即可呼叫這個方法。

要求

HTTP 要求

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

參數

參數名稱 說明
必要參數
blogId string 要取得的網誌 ID。
選用參數
maxPosts unsigned integer 與網誌一併擷取的文章數量上限。如未指定此參數,網誌資源就不會傳回文章。

要求主體

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

回應

如果成功,此方法會在回應主體中傳回網誌資源

範例

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

Java

使用 Java 用戶端程式庫

// The BlogId for the http://code.blogger.com/ blog.
String CODE_BLOG_ID = "3213900";
// Configure the Java API Client for Installed Native App
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
// Configure for 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-BlogGet-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// This is the request action that you can configure before sending the request.
Get blogGetAction = blogger.blogs().get(CODE_BLOG_ID); // Restrict the result content to just the data we need.

blogGetAction.setFields("description,name,posts/totalItems,updated");

// This step sends the request to the server.
Blog blog = blogGetAction.execute();
// Now we can navigate the response.
System.out.println("Name: "+blog.getName());
System.out.println("Description: "+blog.getDescription());
System.out.println("Post Count: "+blog.getPosts().getTotalItems());
System.out.println("Last Updated: "+blog.getUpdated());

試試看!

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