何谓  XML-RPC ? 简单来说就是 XML over HTTP ,使用 XML 格式的资料,在 HTTP 协定上与其他软件沟通。XML-RPC 从 1998 年出现时的原始设计是沟通苹果麦金塔与微软视窗软件之用,使用 XML-RPC 可以让你不用担心无法与其他程式沟通。

XML-RPC 是 XML Web 服务的鼻祖。是一个用于远程过程调用(remote procedure call,RPC)的简单规范,使用 HTTP 作为传输协议,使用 XML 词汇表作为消息有效负载。

XML-RPC是一套规范及其一系列的实现,允许运行在不同操作系统、不同环境的程序基于internet进行远程过程调用(RPC),另一个著名的RPC规范是SOAP,二者之间的区别和联系请参见《 XML-RPC vs. SOAP》。
基于internet标准的简单的跨平台分布式计算”是XML-RPC的口号。

有关XML-RPC的技术规范资料链接:
[url]http://en.wikipedia.org/wiki/Xmlrpc[/url]
[url]http://www.xmlrpc.com[/url]


另外,再提供一些比较有价值的文章参考资源:

zealy 站点的Xml-Rpc接口编程指南
[url]http://www2.blogme.cn/node/view/496[/url]

基于XML-RPC的BloggerAPI学习 
[url]http://www.donews.net/softbunny/articles/11032.aspx[/url]

Blogger.com API 2.0技术规范(E文)
[url]http://www.blogger.com/developers/api/documentation20.html[/url]


Blogger API


Methods

These are the available methods:
blogger.newPost: Makes a new post to a designated blog. Optionally, will publish the blog after making the post.
blogger.editPost: Edits a given post. Optionally, will publish the blog after making the edit.
blogger.getUsersBlogs: Returns information on all the blogs a given user is a member of.
blogger.getUserInfo: Authenticates a user and returns basic user info (name, email, userid, etc.).
blogger.getTemplate: Returns the main or archive index template of a given blog.
blogger.setTemplate: Edits the main or archive index template of a given blog.

RFC: MetaWeblog API


What is the MetaWeblog API? leftArrow.gif

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.

Relationship between MetaWeblog API and the Blogger API leftArrow.gif

The MetaWeblog API is designed to enhance the Blogger API, which was limited in that it could only get and set the text of weblog posts. By the time MWA was introduced, in spring 2002, many weblog tools had more data stored with each post, and without an API that understood the extra data, content creation and editing tools could not access the data.

At the time of this writing, summer 2003, most popular weblog tools and editors support both the Blogger API and the MetaWeblog API.

Relationship between MetaWeblog API and RSS 2.0 leftArrow.gif

The MetaWeblog API uses an XML-RPC struct to represent a weblog post. Rather than invent a new vocabulary for the metadata of a weblog post, we use the vocabulary for an item in RSS 2.0. So you can refer to a post's title, link and description; or its author, comments, enclosure, guid, etc using the already-familiar names given to those elements in RSS 2.0. Further since RSS 2.0 is extensible, so is the MetaWeblog API. We have designed conventions for representing attributes and namespaces in MWA.

Basic entry-points leftArrow.gif

There are three basic entry-points in the API:

metaWeblog.newPost (blogid, username, password, struct, publish) returns string

metaWeblog.editPost (postid, username, password, struct, publish) returns true

metaWeblog.getPost (postid, username, password) returns struct

The blogid, username, password and publish params are as in the Blogger API. newPost returns a string representation of the post id, again as defined by the Blogger API. The struct is where the juice is.

The struct leftArrow.gif

In newPost and editPost, content is not a string, as it is in the Blogger API, it's a struct. The defined members of struct are the elements of <item> in RSS 2.0, providing a rich variety of item-level metadata, with well-understood applications.

The three basic elements are title, link and description. For blogging tools that don't support titles and links, the description element holds what the Blogger API refers to as "content."

Where an element has attributes, for example, enclosure, pass a struct with sub-elements whose names match the names of the attributes according to the RSS 2.0 spec, url, length and type.

For the source element, pass a struct with sub-elements, url and name.

For categories, pass an array of strings of names of categories that the post belongs to, named categories. On the server side, it's not an error if the category doesn't exist, only record categories for ones that do exist.

In getPost, the returned value is a struct, as with the Blogger API, but it contains extra elements corresponding to the struct passed to newPost and editPost.

The server must ignore all elements that it doesn't understand.

In a call to metaWeblog.newPost or metaWeblog.editPost, if the struct contains a boolean named flNotOnHomePage, then the post does not appear on the home page, and only appears on the specified category pages.

Request and response leftArrow.gif

Here's an example of a request and a response.

Here's the post that this request is getting info about.

metaWeblog.newMediaObject leftArrow.gif

metaWeblog.newMediaObject (blogid, username, password, struct) returns struct

The blogid, username and password params are as in the Blogger API.

The struct must contain at least three elements, name, type and bits.

name is a string, it may be used to determine the name of the file that stores the object, or to display it in a list of objects. It determines how the weblog refers to the object. If the name is the same as an existing object stored in the weblog, it may replace the existing object.

type is a string, it indicates the type of the object, it's a standard MIME type, like audio/mpeg or p_w_picpath/jpeg or video/quicktime.

bits is a base64-encoded binary value containing the content of the object.

The struct may contain other elements, which may or may not be stored by the content management system.

If newMediaObject fails, it throws an error. If it succeeds, it returns a struct, which must contain at least one element, url, which is the url through which the object can be accessed. It must be either an FTP or HTTP url.

metaWeblog.getCategories leftArrow.gif

metaWeblog.getCategories (blogid, username, password) returns struct

The struct returned contains one struct for each category, containing the following elements: description, htmlUrl and rssUrl.

This entry-point allows editing tools to offer category-routing as a feature.

metaWeblog.getRecentPosts leftArrow.gif

metaWeblog.getRecentPosts (blogid, username, password, numberOfPosts) returns array of structs

Each struct represents a recent weblog post, containing the same information that a call to metaWeblog.getPost would return.

If numberOfPosts is 1, you get the most recent post. If it's 2 you also get the second most recent post, as the second array element. If numberOfPosts is greater than the number of posts in the weblog you get all the posts in the weblog.

Transmitting elements with attributes leftArrow.gif

The members of the struct passed in newPost and editPost come from the elements of items in RSS 2.0. The most commonly used core elements have no attributes, so it's clear how to include them in the struct. However, some elements, such as source, enclosure and category, may have attributes and a value. Here are a simple set of rules for elements that have attributes and a value. Note that these rules do not apply to enclosure and source, which are provided for specifically above.

1. If an element has attributes, then represent the element with a struct, and include the attributes as sub-elements of the struct.

2. If an element has both attributes and a value, make the element a struct, include the attributes as sub-elements, and create a sub-element for the value with the name _value. Note that this means that no element can be passed through the API that has an attribute whose name is _value.

Transmitting elements from namespaces leftArrow.gif

RSS 2.0 allows for the use of namespaces. If you wish to transmit an element that is part of a namespace include a sub-struct in the struct passed to newPost and editPost whose name is the URL that specifies the namespace. The sub-element(s) of the struct are the value(s) from the namespace that you wish to transmit.

Comments leftArrow.gif

The Blogger API provides a parameter called appkey that allows vendors to assign a key to developers so they can track and possibly limit usage of the API for certain tools. The MetaWeblog API doesn't specifically provide a parameter for an appkey. Applications that wish to transmit an appkey should add an element to the struct called appkey and set its value to the appkey that should be associated with the call.

Applications should use the fault-response scheme defined by XML-RPC. For example, trying to create, get, or edit a post without a valid username-password should generate a fault. Client applications should display the error string, as appropriate, to the user, for example, in a dialog, or in a server log.







Almost every standard compliant blogs support three blogging API which are “Blogger API” , “MovableType API” and “MetaWeblog API”. Among these MW (or MetaWeblog) is used more than other two. Wordpress also supporst these three sets of API. If you are interesetd how to interact with these API’s - then take a look at the following example.
First lets discover which XMLRPC methods are suported by wordpress XMLRPC server. Just execute the following script
system.multicall
system.listMethods
system.getCapabilities
demo.addTwoNumbers
demo.sayHello
pingback.extensions.getPingbacks
pingback.ping
mt.publishPost
mt.getTrackbackPings
mt.supportedTextFilters
mt.supportedMethods
mt.setPostCategories
mt.getPostCategories
mt.getRecentPostTitles
mt.getCategoryList
metaWeblog.getUsersBlogs
metaWeblog.setTemplate
metaWeblog.getTemplate
metaWeblog.deletePost
metaWeblog.newMediaObject
metaWeblog.getCategories
metaWeblog.getRecentPosts
metaWeblog.getPost
metaWeblog.editPost
metaWeblog.newPost
blogger.deletePost
blogger.editPost
blogger.newPost
blogger.setTemplate
blogger.getTemplate
blogger.getRecentPosts
blogger.getPost
blogger.getUserInfo
blogger.getUsersBlogs
so to make a new post using metaWeblog.newPost method lets take a look at the following example.
<?php
include("xmlrpc.inc.php");
$c = new xmlrpc_client("/wp/xmlrpc.php", "localhost", 80);

$content['title']="XMLRPC Post";
$content['description']="Some content posted using MetaWeblog API";
$content['categories'] = array("frontpage");
$x = new xmlrpcmsg("metaWeblog.newPost",
array(php_xmlrpc_encode("1"),
php_xmlrpc_encode("admin"),
php_xmlrpc_encode("root"),
php_xmlrpc_encode($content),
php_xmlrpc_encode("1")));

$c->return_type = 'phpvals';
$r =$c->send($x);
if ($r->errno=="0")
echo "Successfully Posted";
else {
echo "There are some error";
print_r($r);
}
?>