Search This Blog

Thursday, January 22, 2009

Get Comments for Blogger Blog

.Net Documentation for Blogger API from Google
Very easy but I need to remember the following (and I know I won't :)

Getting comments for all posts on the blog, use
http://www.blogger.com/feeds/blogID/comments/default
This link does not appear in list of links on AtomEntry.Links
AtomEntry.Links[3] was
http://www.blogger.com/feeds/blogID/posts/default
and I simply replaced "posts" with "comments" and then queried the blogger web service.

private void GetComments(AtomEntry blog, string login, string password)
{
Service bloggerService = new Service("blogger", "WebPhotoTool.Accounts");
bloggerService.Credentials = new GDataCredentials(login, password);

FeedQuery query = new FeedQuery();
query.Uri = new Uri(
blog.Links[3].AbsoluteUri.ToString().Replace("posts","comments"));
AtomFeed feed = _bloggerService.Query(query);
foreach (AtomEntry entry in feed.Entries)
{
}
}

No comments: