2016-07-17 14 views
1

私はyoutubeのビデオからコメントを抽出しようとしています。私はコメント(https://developers.google.com/youtube/v3/docs/commentThreads/list#try-it)を取得することができますが、個々のコメントの返信を取得する方法を特定することはできません。 Youtube APIのドキュメントを見ましたが、コメントの返信を取得する方法を正確に特定できません。誰でも私にそれが可能であれば教えてもらえますか?はいの場合、どうすればいいですか?ありがとう。Youtubeの返信返信

答えて

0

このdocumentationから、返信を取得するコメントのIDを指定するparentIdパラメータを使用できます。 YouTubeは現在、トップレベルのコメントのみの返信をサポートしており、返信への返信は将来サポートされる可能性があることに注意してください。 comments.listメソッドを使用すると、コメントの返信を取得できます。

例:

//Call the YouTube Data API's comments.list method to retrieve existing comment replies. 

V3CommentListResponse 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"); 

この関連threadにチェックします。