Posting to Community Server from C# using the MetaWeblog API
What is the MetaWeblog API?
The MetaWeblog API (MWA) is a programming interface that allows external programs to get and set the text and attributes of weblog posts. It builds on the popular XML-RPC communication protocol, with implementations available in many popular programming environments. Read more here…
Since this API is exposed from the Weblogs providers, programmer have to use a client-side programming model to communicate with it according to the XML-RPC protocol. Josh Gough has created and published this C# programming wrapper which allows us to easily develop C# client applications that consumes this API via a service.
How do you get started ?
-
Download the Community Server MetaWeblog Proxy assemblies.
-
Create a .Net application and reference the CookComputing.XmlRpc that come in the above .zip file.
-
Create a class for the API provided by Josh Gough. You can copy the contents of the API from his post.
-
Notice that the above post contains an implemention of IBlogger interface, which is decorated with [XmlRpcUrl("…metablog.ashx")] attribute. Don't forget to change the URL of your Community Server Blogs metaBlog.
-
Now you can easily use the proxy in your code.
Example:
using MetaBlogAPI;
IBlogger proxy = MetaBlogAPIFactory.Create();
string user = "user";
string password = "password";
string blogid = "bursteg";
// Create a post. There are some optional properties such as Categories
// that were not supplied in this sample.
Post p = new Post();p.title = "Bloging from C# code";
p.dateCreated = DateTime.Now;
p.description = "Can you see it?";
string postid = proxy.newPost(blogid, user, password, p, true);
Great, isn't it?
My next step is to write a workflow activity that posts an entry to my blog. Look forward for it!
Enjoy!