您可以在檢索評論回覆使用comments.list
method。下面是一個example:
// Call the YouTube Data API's comments.list method to retrieve
// existing comment
// replies.
CommentListResponse commentsListResponse = youtube.comments().list("snippet")
.setParentId(parentId).setTextFormat("plainText").execute();
List<Comment> comments = commentsListResponse.getItems();
if (comments.isEmpty()) {
System.out.println("Can't get comment replies.");
} else {
// Print information from the API response.
System.out
.println("\n================== Returned Comment Replies ==================\n");
for (Comment commentReply : comments) {
snippet = commentReply.getSnippet();
System.out.println(" - Author: " + snippet.getAuthorDisplayName());
System.out.println(" - Comment: " + snippet.getTextDisplay());
System.out
.println("\n-------------------------------------------------------------\n");
}
Comment firstCommentReply = comments.get(0);
firstCommentReply.getSnippet().setTextOriginal("updated");
Comment commentUpdateResponse = youtube.comments()
.update("snippet", firstCommentReply).execute();
// Print information from the API response.
System.out
.println("\n================== Updated Video Comment ==================\n");
snippet = commentUpdateResponse.getSnippet();
System.out.println(" - Author: " + snippet.getAuthorDisplayName());
System.out.println(" - Comment: " + snippet.getTextDisplay());
System.out
.println("\n-------------------------------------------------------------\n");
至於喜歡,你可能要檢查出snippet.viewerRating
。
觀衆已經給這個評論的評級。請注意,這家酒店目前並不確定dislike
的收視率,但這種行爲可能會改變。在此期間,該屬性值是like
如果觀衆評爲評論積極。該值是被給沒有在其他情況下,包括用戶評論負面的評級或者沒有評級的評論。該物業
有效值:
然後檢查snippet.likeCount
得到喜歡的總數(正面評級)的評論已收到。
這裏的sample JSON structure,顯示了comments
資源的格式。
{
"kind": "youtube#comment",
"etag": etag,
"id": string,
"snippet": {
......
"authorChannelId": {
"value": string
},
......
"viewerRating": string,
"likeCount": unsigned integer,
......
}
}
希望這有助於!