註解:get

commentId 擷取一個註解資源。 立即試用查看範例

如果留言是位於私人網誌上,則必須取得授權。如果是公開留言的網誌,則可在未經授權的情況下呼叫此方法。

要求

HTTP 要求

GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId/comments/commentId

參數

參數名稱 價值 說明
必要參數
blogId string 包含留言的網誌 ID。
commentId string 要取得的註解 ID。
postId string 要擷取留言的貼文 ID。

要求主體

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

回覆

如果成功,這個方法會在回應主體中傳回註解資源

示例

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

Java

使用 Java 用戶端程式庫

// The BlogId for the http://buzz.blogger.com/ blog.
String BUZZ_BLOG_ID = "2399953";
// The PostId for a buzz post with comments.
String BUZZ_POST_ID = "5310628572012276714";
// The CommentId for a comment on the above post.
String BUZZ_COMMENT_ID = "6352433676268819946";
// 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-CommentsGet-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
Get commentsGetAction = blogger.comments().get(BUZZ_BLOG_ID,
BUZZ_POST_ID, BUZZ_COMMENT_ID);
// Restrict the result content to just the data we need.
commentsGetAction.setFields("author/displayName,content");
// This step sends the request to the server.
Comment comment = commentsGetAction.execute();
// Now we can navigate the response.
System.out.println("Display Name: " + comment.getAuthor().getDisplayName());
System.out.println("Content: " + comment.getContent());

試試看!

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