Tuesday, December 18, 2007

Can not update a read-only feed

The following C# code will allow you to add a blog entry in blogger:

string blogId = "9999999999999999999"; //your blogger id
Cursor.Current = Cursors.WaitCursor;
Service service = new Service("blogger", "BloggerApp");
// Set your credentials:
service.setUserCredentials("email@gmail.com", "password");

string token = service.QueryAuthenticationToken();
service.SetAuthenticationToken(token);

AtomEntry newPost = new AtomEntry();
newPost.Title.Text = "Test Publish!";
newPost.Content = new AtomContent();
newPost.Content.Content = "
" +
"

Automated test publish.

" +
"
";
newPost.Content.Type = "xhtml";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = "you name here";
newPost.Authors[0].Email = "email@gmail.com";
newPost.Service = service;

FeedQuery query = new FeedQuery();
// Create the query object:
query.Uri = new Uri("http://www.blogger.com/feeds/" + blogId + "/posts/default");

// Tell the service to query:
AtomFeed bloggerFeed = service.Query(query);
AtomEntry createdEntry = service.Insert(bloggerFeed, newPost);
Cursor.Current = Cursors.Default;

1 comment:

Bob Newman said...

Is this how you clog the internets?