I want to get all comments (up to 999) from a youtube video. This is the URL that i want to send
http://gdata.youtube.com/feeds/api/videos/1EEFydL6ooA/comments?start-index=1&max-results=50
When I send this URL i am getting 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), found (http://www.w3.org/2005/Atom:feed
Actually, when my URL was "http://gdata.youtube.com/feeds/api/videos/1EEFydL6ooA", I was getting 25 comments if any. However since this is about one single video, I was not able to set max-results and start-index parameter. My code is :
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();
Why am I getting parseException? Maybe because this code works accordingly VideoEntry object and parsing is done in this way. Is there something like CommentEntry? How can initiliaze it if any?
Note that my exception is not " com.google.gdata.util.ParseException: [Line 1, Column 101152, element yt:state] Invalid value for attribute : 'name' " which is due to wrong library.
Thanks