$xmlrpc->credentials( 'username', 'password ).$xmlrpc = XML::RPC->new( '', %options ).In part II, I will look at how we implement an XML-RPC client to ping blogging servers. Return letePost(appKey, postid, username, password, publish) Public bool MWLDeletePost(string appKey, string postid, string username, string password, bool publish) To overcome the issue with some blog editors calling letePost rather than letePost, you simply create an additional method to handle this and then call your other method i.e. Once we have written our methods we can build and browse to our MetaWebLog.ashx file and if all is working the methods should be listed in the browser. XML-RPC also handles Arrays and in the MetaWebLog API, the MetaWebLog.getRecentPosts needs to return each post as an element of an array of XmlRpcStructs. We create a new XML-RPC object and then use the Add method to add each parameter name (key) and value. We need to respond within a nested XML element / struct with specific parameter names, to do this we use the XmlRpcStruct object. I would normally use the post ID to query a database but here I have hard coded the response. If we are not authorized I use the Response object to return a 403 – Not Authorised message, else we can continue. We first want to check the username and password are valid, I have an Authenticate method to do this. In this example we are being sent a blog post item id, and a username and password. Rpcstruct.Add("publish", true) return rpcstruct Rpcstruct.Add("categories", new string ) XmlRpcStruct rpcstruct = new XmlRpcStruct() We need to create an XML-RPC Struct to return Public XmlRpcStruct getPost(string postid, string username, string password) I will not go through each method but rather show you one as an example of how to work with an XML-RPC request. prefix instead.įor each of these methods we need to make a compiler declaration before the method to indicate the XML-RPC method name. although these are defined by XML-RPC like this, some MetaWebLog API clients call these methods with the metaWebLog. Note: I have found that with the last three methods prefixed blogger. We basically need to implement the following methods: However, I was able to find a definition on MSDN which was very helpful. We can now create our methods, the MetaWebLog API is documented at the XML-RPC site, but again it is not very clear. The Name parameter indicates the name of our service, in this case MetaWebLogApi, there is a description and the AutoDocumentation allows us to browse to the XML-RPC service (.ashx generic handler file) and see the available methods. Public class MetaWebLogHandler : XmlRpcService Once we have done that we need to alter the class definition as follows passing some parameters to the XML-RPC service and inheriting the class from XmlRpcService as follows: [XmlRpcService(Name = "MetaWebLogApi",ĭescription = "This is XML-RPC which implement MetaWeblog API.", Within this file we first need to reference the CookComputing.XmlRpc package as follows: using CookComputing.XmlRpc I now need to create my MetaWebLogHandler.cs class file in the App_Code directory. You can now create or consume an XML-RPC service.įor this example I am going to implement the MetaWebLog API in C# to do this we need to add two files to our project, a generic handler and a class file to handler requests to the generic handler.įor this example I will create a handler named MetaWebLog.ashx and it will contain simply the following webhandler directive: Once extracted you will need to copy this. zip archive: This is the core component you will need:įor. Once you have downloaded the latest version, extract only the following file from the. Although I think the XML-RPC implementation is an excellent stable offering, the documentation is a little sketchy and hard to follow at times which is why I am posting this tutorial. Net XML-RPC implementation from CooksComputing. To start working with XML-RPC, the first thing you will need to do in download the. You can create an XML-RPC server or client easily within an existing project. Net XML-RPC framework already exists for use in ASP.Net, which has been developed by Charles Cook of CookComputing. The MetaWebLog API runs over XML-RPC an open standard for HTTP based remote procedure calls and is the standard api protocol for blog platforms. My tutorial below will show you how to easily create or consume an XML-RPC service such as the MetaWebLog API. I have recently be working on a project which needed to implement the blogging MetaWebLog API, allowing users to post blog messages from their favorite blog editor, such as Windows Live Writer or blog directly from MetaWebLog API enabled websites such as Flickr or Digg.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |