0

I have set up everything according from the guide here : https://developers.google.com/gdata/articles/eclipse

From there on, how do I start to retrieve the comments? I'm sort of a beginner so it would be great if anyone could provide some codes to start off.

4

1 回答 1

0

首先,您应该下载库并安装链接所在页面中显示的所需库。

要从 youtube 视频中获取评论,您应该发送此 URL: http: //gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments

    YouTubeService service = new YouTubeService(
            YOUR_CLIENT_ID);
    String url="http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments";    
    VideoEntry videoEntry = service.getEntry(new URL(url),
                        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());
        }

您可以通过此代码获得最后 25 条评论。如果你想获得超过 25 条评论,你应该阅读分页、最大结果、开始索引参数。

于 2013-08-29T12:10:14.627 回答