博客: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());

试试看!

请使用下面的 API Explorer 针对实际数据调用此方法,然后查看响应。