如果網誌設為私人,則必須授權。如果網誌是公開的,則可不經授權呼叫這個方法。
要求
HTTP 要求
GET https://www.googleapis.com/blogger/v3/blogs/blogId
參數
| 參數名稱 | 值 | 說明 |
|---|---|---|
| 必要參數 | ||
blogId |
string |
要取得的網誌 ID。 |
| 選用參數 | ||
maxPosts |
unsigned integer |
要連同網誌一併擷取的文章數量上限。如果未指定這項參數,系統不會傳回任何網誌資源的貼文。 |
要求主體
請勿透過此方法提供要求主體。
回應
如果成功,這個方法會在回應內文中傳回 Blogs 資源。
範例
注意:這個方法適用的程式設計語言眾多,我們只在此提供部分程式碼範例。如需查看所有支援語言,請參閱用戶端程式庫頁面。
Java
使用 Java 用戶端程式庫
// The BlogId for the http://code.blogger.com/ blog.
String CODE_BLOG_ID = "3213900";
// Configure the Java API Client for Installed Native AppHttpTr
ansport HTTP_TRANSPORT = new NetHttpTransport();JsonFa
ctory JSON_FACTORY = new JacksonFactory(); class="devsite-syntax-c1">// Configure for the Installed App OAuth2 flow.Credential c
redential = OAuth2Native.authorize(HTTP_TRANSPORT, JSON_FACTOR
Y, new LocalServerReceiver(), Arrays.asLi
st(BloggerScopes.BLOGGER));span> <span class
="devsite-syntax-c1">// Construct the Blogger API access facade object.Blogger blogger =
Blogger.builder(HTTP_TRANSPORT, JSON_FACTORY) .setApplicationNa
me("Blogger-BlogGet-Snippet/1.0") .setHttpRequestIn
itializer(credential).build(); // This is the request action that you can configure before sending the request.Get blogGetAction = blog
ger.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 r
equest to the server.Blog blog = blogGetActio
n.execute(); // Now we can navigate the response.System.out.println("Name
: "+blog.getName());System.out.println("Desc
ription: "+blog.getDescription());System.out.println("Post
Count: "+blog.getPosts().getTotalItems());System.out.println("Last
Updated: "+blog.getUpdated());an>
試試看!
您可以使用下方的 API Explorer,針對即時資料呼叫這個方法,然後查看回應。