http://code.google.com/p/google-gdata/downloads/list
Add a reference to "Google Data API Core Library",
and use the following function:
public static bool AddPost(string title, string bodyHTML, string[] labels)
{
Service service = new Service("blogger", "<program name>");
service.Credentials = new GDataCredentials("<username>", "<password>");
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = title;
newPost.Content = new AtomContent();
newPost.Content.Content = bodyHTML;
newPost.Content.Type = "html";
foreach (string label in labels)
{
AtomCategory cat = new AtomCategory();
cat.Scheme = new Uri("http://www.blogger.com/atom/ns#");
cat.Term = label;
newPost.Categories.Add(cat);
}
AtomEntry response = null;
try
{
response = service.Insert(new Uri("<uri>"), newPost);
}
catch (GDataRequestException exception)
{
if (exception.ResponseString == "Blog has exceeded rate limit or otherwise requires word verification for new posts")
{
return false;
}
else
{
throw exception;
}
}
if (response == null)
{
throw new Exception("Something went wrong");
}
return true;
}
Note what you need to replace:
- <program name>
- <username>
- <password>
- <uri> is for example: http://ycouriel.blogspot.com/feeds/posts/default
Great post! Thank you.
ReplyDeleteIts not working for me :S In try{} something goes wrong but the code in catch not running, and lots of stuff will be posted, or nothing... Please help!
ReplyDeleteresponse = service.Insert(new Uri("http://www.blogger.com/feeds/" + BLOG_ID + "/posts/default"), newPost);
Deletetry change this help for me
but its working for me thanks
ReplyDeletemore clear if you share it on youtube video
ReplyDeleteHi, i get this error. Please help me
ReplyDelete{"Execution of authentication request returned unexpected result: 404"}
Know the features, advantages and the major difference between Java and Python with the emphasized examples from the best software training institute in Chennai, Infycle Technologies. Dial +91-7504633633 or +91-7502633633 to know the best offers and get the free demo for the combo of Python + Java
ReplyDeletesalt likit
ReplyDeletesalt likit
dr mood likit
big boss likit
dl likit
dark likit
LX4ONO