我想从 youtube 视频中获取所有评论(最多 999 条)。这是我要发送的 URL
http://gdata.youtube.com/feeds/api/videos/1EEFydL6ooA/comments?start-index=1&max-results=50
当我发送此 URL 时,我收到com.google.gdata.util.ParseException [Line 1, Column 279] Invalid root element, expected (namespace uri:local name) of ( http://www.w3.org/2005/ Atom:entry ),找到 ( http://www.w3.org/2005/Atom:feed
实际上,当我的 URL 是“ http://gdata.youtube.com/feeds/api/videos/1EEFydL6ooA ”时,我收到了 25 条评论(如果有的话)。但是,由于这是关于一个视频,我无法设置 max-results 和 start-index 参数。我的代码是:
    String str = "http://gdata.youtube.com/feeds/api/videos/" + videoId
        + "/comments";
    YouTubeQuery youtubeQuery = new YouTubeQuery(new URL(str));
    youtubeQuery.setMaxResults(50);
    youtubeQuery.setStartIndex(1);
    String videoEntryUrl = youtubeQuery.getUrl().toString();
    VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl),
            VideoEntry.class);
    if (videoEntry.getComments() != null) {
        String commentUrl = videoEntry.getComments().getFeedLink()
                .getHref();
        System.out.println(commentUrl);
        CommentFeed commentFeed = service.getFeed(new URL(commentUrl),
                CommentFeed.class);
        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();
为什么我会收到 parseException?可能是因为这段代码相应地工作 VideoEntry 对象并以这种方式完成解析。有没有像 CommentEntry 这样的东西?如果有的话如何启动它?
请注意,我的例外不是“ com.google.gdata.util.ParseException: [Line 1, Column 101152, element yt:state] Invalid value for attribute : 'name' ”,这是由于库错误。
谢谢