Search This Blog

Showing posts with label Blogger API. Show all posts
Showing posts with label Blogger API. Show all posts

Sunday, September 20, 2009

Query for Blog posts by date


FeedQuery query = new FeedQuery();
query.Uri = new Uri("http://www.blogger.com/feeds/" + blogId + "/posts/default");
query.MinPublication = new DateTime(2006, 1, 1);
query.MaxPublication = new DateTime(2007, 4, 12);
AtomFeed feed = service.Query(query);
foreach (AtomEntry entry in feed.Entries)
{
Console.WriteLine(" Entry Title: " + entry.Title.Text);
}

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)
{
}
}