תגובות: רשימה

אחזור רשימת התגובות לפוסט. אפשר לנסות עכשיו או לראות דוגמה.

נדרשת הרשאה אם התגובות הן בבלוג פרטי. אם התגובות הן בבלוג ציבורי, ניתן לקרוא לשיטה הזו ללא הרשאה.

בקשה

בקשת HTTP

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

פרמטרים

שם הפרמטר ערך של Gpa education תיאור
פרמטרים נדרשים
blogId string מזהה הבלוג שממנו רוצים לאחזר את התגובות.
postId string מזהה הפוסט שממנו יש לאחזר את התגובות.
פרמטרים אופציונליים
endDate datetime התאריך האחרון של התגובה לאחזור, שעה בפורמט RFC 3339.
fetchBodies boolean האם כולל תוכן התגובות.
maxResults unsigned integer המספר המקסימלי של תגובות שאפשר לכלול בתוצאה.
pageToken string אסימון המשך אם הבקשה מקבלת דפים.
startDate datetime התאריך המוקדם ביותר לאחזור התגובה, שעה בפורמט RFC 3339.
status string

הערכים הקבילים הם:
  • "emptied": תגובות שהתוכן שלהן הוסר
  • 'live': תגובות שגלויות לכולם
  • 'pending': תגובות שממתינות לאישור האדמין
  • "spam": תגובות שסומנו כספאם על ידי האדמין
view string

הערכים הקבילים הם:
  • "ADMIN": פרטים ברמת האדמין
  • "AUTHOR": פרטים ברמת המחבר
  • "READER": פרטים ברמת האדמין

גוף הבקשה

אל תספקו גוף בקשה בשיטה הזו.

תשובה

אם הפעולה בוצעה ללא שגיאות, השיטה הזו מחזירה גוף תגובה עם המבנה הבא:

{
  "kind": "blogger#commentList",
  "nextPageToken": string,
  "prevPageToken": string,
  "items": [
    comments Resource
  ]
}
שם הנכס ערך של Gpa education תיאור הערות
kind string סוג הרשומה הזו. תמיד blogger#commentList.
nextPageToken string אסימון העימוד שמשמש לאחזור הדף הבא, אם קיים.
prevPageToken string אסימון העימוד שמשמש לאחזור הדף הקודם, אם קיים.
items[] list רשימת משאבי התגובות לפוסט שצוין.

דוגמאות

הערה: דוגמאות הקוד הזמינות לשיטה זו לא מייצגות את כל שפות התכנות הנתמכות (רשימת השפות הנתמכות זמינה בדף של ספריות המשתמשים).

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";
// 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();

}

רוצה לנסות?

אפשר להשתמש ב-APIs Explorer שבהמשך כדי להפעיל את השיטה הזו בנתונים בזמן אמת ולראות את התגובה.