Introduction to Windows Live writer and XML-RPC
(An article written very earlyArticle, Throwing it back up)
Windows Live writer is a tool released by Microsoft to edit and publish blogs without a browser. It supports HTML and simple image editing and uploading, which greatly facilitates blog editing and publishing. currently, Windows Live writer supports large blog services outside China, such as live spaces and blogger. If you want to use Windows Live writer without using the services in the support list, you only need to add XML-RPC support to your blog.
XML-RPC is a remote call service similar to WebService, But it supports more platforms than WebService, windows Live writer and many other offline blog editing and publishing tools use XML-RPC to call the blogProgramMethod.
This document uses ASP. net is used as an example to add XML-RPC support for Windows Live writer to the blog. This allows us to edit, publish, and modify blog entries in live writer, if your blog is on another platform, see
Http://www.xmlrpc.com/directory/1568/implementatio... to find out how to implement XML-RPC on your platform. although the methods for implementing XML-RPC on different platforms are different, the steps for adding interfaces supported by Windows Live writer are similar.
Preparations
For the ASP. NET platform, first download the components supported by XML-rpc in the http://www.xml-rpc.net/, decompressCookcomputing. xmlrpcv2.dllCopy to the bin folder of the ASP. NET program andMetaweblogapi. CSCopy to the app_code folder (of course, other folders of the ASP. NET program can also be copied )..
Start
First modifyMetaweblogapi. CSFile. This is one of the interfaces supported by Windows Live writer, but you must add a method to it to normally support Windows Live writer.
Add a struct:
Public StructUserblog {Public StringURL;Public StringBlogid;Public StringBlogname ;}
This is the structure used to save the blog Information
ThenImetaweblogInterface to add a method:
[Xmlrpcmethod ("Blogger. getusersblogs")] Userblog [] getusersblogs (StringAppkey,StringUsername,StringPassword );
XmlrpcmethodThe method name specified in XML-RPC cannot be changed. The. client cannot identify and call the method.
The interface file is ready. Now the interface method is implemented.
Add an ashx file in the root directory of the ASP. NET program. Suppose it is rpc. ashx. The following provides an example of rpc. ashx:
<% @ Webhandler Language = " C # " Class = " Rpcservice " %> <! -- Registration type --> <% @ Assembly name = " Cookcomputing. xmlrpcv2 " %> <! -- Register cookcomputing. xmlrpcv2.dll for implementation of XMLRPC --> Using System; Using System. collections; Using System. Web; Using Cookcomputing. XMLRPC; // Introduce XMLRPC Using Cookcomputing. metaweblog; // Introduce imetaweblog Interface Using Dataaccess; // Introduce your own blog program to access namespace [Xmlrpcservice (Description = " Metaweblog XML-RPC Service " )] Public Class Rpcservice: xmlrpcservice, imetaweblog { # Region Imetaweblog Member // Retrieve blog site information Public Userblog [] getusersblogs ( String Appkey, String Username, String Password ){ If (LOGIN (username, password )) // Verify the username and password. You must implement this method in this class. {Userblog blog = New Userblog (); blog. blogid = "" ; // Just a blog. This is not required. Blog. blogname = " Lifebeta " ; // Blogname. Just write it. Blog. url = " Http://aspspider.org/lifebeta/ " ; // Blog URL Return New Userblog [] {blog };} Return Null ;} // Add blog Public String Newpost ( String Blogid, String Username, String Password, post, Bool Publish ){ If (LOGIN (username, password )){ // Use your own dataaccess Return Dataaccess. addblog (post. Title, post. description, 4 , "" , False , Datetime. Now. addhours ( 12 ). Tostring ();} Return Null ;} // Edit blog Public Object Editpost ( String Postid, String Username, String Password, post, Bool Publish ){ If (LOGIN (username, password )){ // Use your own dataaccess. Note that post. title is the title and post. description is the Blog content. Dataaccess. editblog (convert. toint32 (postid), post. Title, post. description, 4 , "" , False );} Return Null ;}// Obtain a category Public Categoryinfo [] getcategories ( String Blogid, String Username, String Password ){ If (LOGIN (username, password )){ // Omitted } Return Null ;}// Get the article Public Post getpost ( String Postid, String Username, String Password ){ If (LOGIN (username, password )){ // Omitted } Return New Post ();} // Obtain the latest published article Public Post [] getrecentposts ( String Blogid, String Username, String Password, Int Numberofposts ){ If (LOGIN (username, password )){ // Omitted } Return Null ;}// Publish a media object Public Urldata newmediaobject ( String Blogid, String Username, String Password, filedata file ){ If (LOGIN (username, password )) Return New Urldata ();} Return New Urldata ();}// Custom Method Public Bool Login ( String Username, String Pass ){ // Used to verify the user } # Endregion }
OK .. this is almost the case .. enter this ashx in the browser to check whether the above implementation method list and data type are available, just like the local test page of WebService. however, XML-RPC cannot be tested locally. now you can try it with Windows Live writer.
Use Windows Live writer to publish a blog
Like adding other blog sites, You must select metaweblog (custom) when selecting the blog service. Enter the path of the ashx file for the script address.
Success! Because the XML-RPC solution prepared by others is used, it is quite simple to implement it. because live writer is still in beta stage, there are still some imperfections ,.. we look forward to the official version of live writer ..