เรียกข้อมูลรายการความคิดเห็นสำหรับโพสต์ ลองเลยหรือดูตัวอย่าง
ต้องใช้การให้สิทธิ์หากความคิดเห็นอยู่ในบล็อกส่วนตัว ถ้าความคิดเห็นอยู่ในบล็อกแบบสาธารณะ จะสามารถเรียกใช้วิธีการนี้โดยไม่ได้รับอนุญาต
ส่งคำขอ
คำขอ HTTP
GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId/comments
พารามิเตอร์
| ชื่อพารามิเตอร์ | ค่า | คำอธิบาย | 
|---|---|---|
| พารามิเตอร์ที่จำเป็น | ||
| blogId | string | รหัสของบล็อกที่จะดึงข้อมูลความคิดเห็น | 
| postId | string | รหัสของโพสต์ที่จะดึงข้อมูลความคิดเห็น | 
| พารามิเตอร์ที่ไม่บังคับ | ||
| endDate | datetime | วันที่ของความคิดเห็นล่าสุดที่จะดึงข้อมูล วันที่และเวลาที่ใช้การจัดรูปแบบ RFC 3339 | 
| fetchBodies | boolean | รวมเนื้อหาเนื้อหาของความคิดเห็นหรือไม่ | 
| maxResults | unsigned integer | จำนวนความคิดเห็นสูงสุดที่จะรวมไว้ในผลลัพธ์ | 
| pageToken | string | โทเค็นต่อเนื่องหากมีการแบ่งหน้าคำขอ | 
| startDate | datetime | วันที่ของความคิดเห็นแรกสุดที่จะดึงข้อมูล ซึ่งเป็นวันที่และเวลาที่ใช้การจัดรูปแบบ RFC 3339 | 
| status | string | ค่าที่ยอมรับได้ มีดังนี้ 
 | 
| view | string | ค่าที่ยอมรับได้ มีดังนี้ 
 | 
เนื้อหาของคำขอ
โปรดอย่าให้เนื้อหาคำขอด้วยวิธีนี้
คำตอบ
หากสำเร็จ เมธอดนี้จะแสดงเนื้อหาการตอบกลับซึ่งมีโครงสร้างต่อไปนี้
{
  "kind": "blogger#commentList",
  "nextPageToken": string,
  "prevPageToken": string,
  "items": [
    comments Resource
  ]
}
    | ชื่อพร็อพเพอร์ตี้ | ค่า | คำอธิบาย | หมายเหตุ | 
|---|---|---|---|
| kind | string | ประเภทของรายการนี้ blogger#commentListเสมอ | |
| nextPageToken | string | โทเค็นการใส่เลขหน้าเพื่อดึงข้อมูลหน้าถัดไป หากมี | |
| prevPageToken | string | โทเค็นการใส่เลขหน้าเพื่อดึงข้อมูลหน้าก่อนหน้า หากมี | |
| items[] | list | รายการทรัพยากรความคิดเห็นสำหรับโพสต์ที่ระบุ | 
ตัวอย่าง
หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)
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";
// 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();}
ลองใช้งาน
ใช้ API Explorer ด้านล่างเพื่อเรียกใช้เมธอดนี้กับข้อมูลแบบสดและดูการตอบกลับ
