Retrieves the list of comments for a post. Try it now or see an example.
Authorization is required if the comments are on a blog that is private. If the comments are on a blog that is public, then this method can be called without authorization.
Request
HTTP request
GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId/comments
Parameters
Parameter name | Value | Description |
---|---|---|
Required parameters | ||
blogId |
string |
The ID of the blog to fetch comments from. |
postId |
string |
The ID of the post to fetch comments from. |
Optional parameters | ||
endDate |
datetime |
Latest date of comment to fetch, a date-time with RFC 3339 formatting. |
fetchBodies |
boolean |
Whether the body content of the comments is included. |
maxResults |
unsigned integer |
Maximum number of comments to include in the result. |
pageToken |
string |
Continuation token if request is paged. |
startDate |
datetime |
Earliest date of comment to fetch, a date-time with RFC 3339 formatting. |
status |
string |
Acceptable values are:
|
view |
string |
Acceptable values are:
|
Request body
Do not supply a request body with this method.
Response
If successful, this method returns a response body with the following structure:
{ "kind": "blogger#commentList", "nextPageToken": string, "prevPageToken": string, "items": [ comments Resource ] }
Property name | Value | Description | Notes |
---|---|---|---|
kind |
string |
The kind of this entry. Always blogger#commentList . |
|
nextPageToken |
string |
Pagination token to fetch the next page, if one exists. | |
prevPageToken |
string |
Pagination token to fetch the previous page, if one exists. | |
items[] |
list |
The list of comments resources for the specified post. |
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Java
Uses the Java client library
// 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";
// 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-CommentsList-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
List commentsListAction = blogger.comments().list(BUZZ_BLOG_ID, BUZZ_POST_ID);
// Restrict the result content to just the data we need.
commentsListAction.setFields("items(author/displayName,content),nextPageToken");
// This step sends the request to the server.
CommentList comments = commentsListAction.execute();
// Now we can navigate the response.
while(comments.getItems() != null && !comments.getItems().isEmpty()){
for(Comment comment : comments.getItems()) {
System.out.println(comment.getAuthor().getDisplayName()+": "+comment.getContent());
}
// Pagination logic
String pageToken = comments.getNextPageToken();
if(pageToken == null) {
break;
}
System.out.println("-- Next page of comments");
commentsListAction.setPageToken(pageToken);
comments = commentsListAction.execute();}
Try it!
Use the APIs Explorer below to call this method on live data and see the response.