With Xml-rpc becoming more and more popular, the MetaWeblog interface is almost the most popular offline blog sending API. It can be added to any blog by standardized WebService interface. Currently, using the MetaWeblog interface to publish offline blog clients is popular or Windows Live writer. Here you can find some of the relevant setup methods.
In other words, how to synchronize multiple blogs with MetaWeblog interface? Of course you can directly set up a number of account to deal with, but obviously cumbersome, also does not conform to our DIY personality.
Because my own personal blog is completely self-written, so it is not thought to write a MetaWeblog interface can make Windows Live Writer connection on the www.dumuzi.cn, and again it added a forwarding module, forwarding other blogs, one at a time many.
Call
Calling the MetaWeblog interface I used xml-rpc.net, an open-source. NET Library, to handle XML-RPC.
The related call is very simple, the online can also find the corresponding demo. Just implement the API for MetaWeblog and blogger in the Imetaweblog interface.
Interface
public interface imetaweblog { #region metaweblog api [xmlrpcmethod ("MetaWeblog.newPost")] string addpost (String blogid, string username, string password, post post, bool publish); [xmlrpcmethod ("Metaweblog.editpost")] bool Updatepost (String postid, string username, string password, post post, bool publish); [xmlrpcmethod ("MetaWeblog.getPost")] post getpost (String postid, string username, string password); [xmlrpcmethod (" Metaweblog.getcategories ")] categoryinfo[] getcategories (string blogid, string username, string password); [xmlrpcmethod ("metaWeblog.getRecentPosts")] post[] getrecentposts (string blogid, string username, string password, int numberofposts); [xmlrpcmethod ("Metaweblog.newmediaobject")] mediaobjectinfo newmediaobject (string blogid, string username, string password, mediaobject mediaobject); #endregion #region Blogger Api [xmlrpcmethod ("Blogger.deletepost")] [return: xmlRpcreturnvalue (description = "returns true.") bool deletepost (string key, string postid, String username, string password, bool publish); [xmlrpcmethod ("Blogger.getusersblogs")] bloginfo[] Getusersblogs (String key, string username, string password); [xmlrpcmethod ("Blogger.getuserinfo")] Userinfo getuserinfo (String key, string username, string password); #endregion } only need to create a class when using,metaweblog The corresponding method of implementing its interface is OK, so that the client can post blog by accessing it public class MetaWeblog : xmlrpcservice, imetaweblog {.... }
A way to write a blog
String Imetaweblog.addpost (String blogID, string Username, string password, post post, bool publish) {if ( ValidateUser (username, password)) {.......... Omit n lines to write to the content of your blog ... return postid;; ";". " } else {throw new xmlrpcfaultexception (0, "Keyword is not valid!"); } }
It is worth noting that due to the different data structure of each blog, may cause some interface call when the meaning of confusion, for example, string blogID originally refers to the current user through getusersblogs return the corresponding ID in multiple blogs, However, some blogs return the blog tag that is returned when the blog is sent successfully, that is, PostID
Specific analysis may be required according to different blogs.
Forward
Forwarding blog is relatively simple, just define a forwarding interface Imetaweblogpost can
public interface imetaweblogpost : ixmlrpcproxy { #region MetaWeblog API [xmlrpcmethod ("Metaweblog.newpost")] string addpost (string blogid, string username, string password, post post, bool publish); [xmlrpcmethod ( "Metaweblog.getcategories")] categoryinfo[] GetCategories (String blogid, string username, string password); [xmlrpcmethod ("Metaweblog.newmediaobject")] mediaobjectinfo newmediaobject (string blogid, string Username, string passwoRd, mediaobject mediaobject) ; #endregion }
The
Call is very simple following the implementation of the Addpost method
String imetaweblog.addpost (String blogid, string username, string password, post post, bool publish)    {  &NBSP, ............ Omit n lines to write the contents of your blog ..................... if ( true)//judgment requires forwarding { try { weblogpost. url = "Http://www.cnblogs.com/yourname/services/metaweblog.aspx"; weblogpost. Addpost (blogid, name, password, post, publish); } catch { throw new Xmlrpcfaultexception (0, "cnblogs sent failed!"); } } }
Of course, you can define some functions such as synchronous deletion, synchronous modification and so on.
Through the above 2 steps, we can easily send their own blog through the MetaWeblog interface and let it forward other blogs
Original address: http://www.jianfangkk.com/aspnet/201510/286
Analysis on using MetaWeblog interface to synchronize multiple blogs