如何使用Java检索超过25条youtube评论

如何使用Java检索超过25条youtube评论,java,youtube,youtube-api,Java,Youtube,Youtube Api,以下是我检索特定视频的youtube评论的代码。 我可以用这段代码检索到大约25条评论,但是如何从视频中检索所有评论呢?我认为这类似于: YouTubeService service = new YouTubeService("MyApp"); String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/nU9dinwMyHo"; VideoEntry videoEntry = servi

以下是我检索特定视频的youtube评论的代码。
我可以用这段代码检索到大约25条评论,但是如何从视频中检索所有评论呢?

我认为这类似于:

      YouTubeService service = new YouTubeService("MyApp");
      String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/nU9dinwMyHo";
      VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class);
      String commentUrl = videoEntry.getComments().getFeedLink().getHref();

      CommentFeed commentFeed = service.getFeed(new URL(commentUrl), CommentFeed.class);
      for(CommentEntry comment : commentFeed.getEntries()) {
        System.out.println(comment.getPlainTextContent());
//获取视频条目
字符串str=”http://gdata.youtube.com/feeds/api/videos/“+视频ID;
YouTubeQuery YouTubeQuery=newyoutubequery(新URL(str));
字符串videoEntryUrl=youtubeQuery.getUrl().toString();
VideoEntry=service.getEntry(新URL(videoEntryUrl),VideoEntry.class);
//获取此视频的评论url
if(videoEntry.getComments()!=null){
String commentUrl=videoEntry.getComments().getFeedLink().getHref();
System.out.println(commentUrl);
//获取注释提要;使用新查询
YouTubeQuery YouTubeQuery=新的YouTubeQuery(新的URL(commentUrl);
setMaxResults(50);
YouTubEquiry.setStartIndex(1);
String commentUrlFeed=youtubeQuery.getUrl().toString();
CommentFeed CommentFeed=service.getFeed(新URL(commentUrlFeed),CommentFeed.class);
//响应应该包含下一个提要(如果有)的url,该提要已经具有更新的开始索引。
对于(int i=0;i
这还能用吗?(对于G+集成)我直到今天才检查我的消息。上面的代码使用的是api版本2,它已被弃用。更改后我不知道,因为我自己没有使用它。
// Get a video entry
String str = "http://gdata.youtube.com/feeds/api/videos/" + videoId;
YouTubeQuery youtubeQuery = new YouTubeQuery(new URL(str));
String videoEntryUrl = youtubeQuery.getUrl().toString();
VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl),VideoEntry.class);

// Get the comments url for this video
if (videoEntry.getComments() != null) {
    String commentUrl = videoEntry.getComments().getFeedLink().getHref();
    System.out.println(commentUrl);

    // Get the comment feed; use a new query
    YouTubeQuery youtubeQuery = new YouTubeQuery(new URL(commentUrl);
    youtubeQuery.setMaxResults(50);


    youtubeQuery.setStartIndex(1);
    String commentUrlFeed = youtubeQuery.getUrl().toString();
    CommentFeed commentFeed = service.getFeed(new URL(commentUrlFeed),CommentFeed.class);
    // The response should contain an url for the next feed, if any, already with an updated start-index.

    for (int i = 0; i < commentFeed.getEntries().size()
            && commentFeed.getEntries().get(i) != null; i++) {

        String author=commentFeed.getEntries().get(i).getAuthors().get(0).getUri().substring(41)
        String commentId=commentFeed.getEntries().get(i).getId().substring(47);
        String comment=commentFeed.getEntries().get(i).getPlainTextContent();
        }
    }
    // Loop thru next comment feed call, if more can be expected.
    // Use updated url from the response or set start-index = start-index + max-results.
 }