See RFC: http://www.xmlrpc.com/MetaWeblogApi for reference on MetaWeblog API.
One user on a site may have multiple blogs, one blog contain multiple posts, one post contain at least title and description attributes, as follwing figure shows.
The most import 3 entry points of metaWeblog are:
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 content of one blog are represented as struct.
you can upload the blog to site without publish to others, so comes the publish parameter to newPost and editPost, this bool value control whether the blog should be published.
There are also methods to list posts get/delete a post which won't be listed here. Final piece of the API is handle mediaObject in Html.
MetaWeblog.newMediaObject (blogid, username, passwd, file) return URL of uploaded file
For these who are curisoty, following Python code demo how to wrap newPost methods and how to use it.
import xmlrpclib
class MetaWeblog:
'''works with www.cnblogs.com atleast'''
def __init__(self, serviceUrl, appKey, usr, passwd):
self.serviceUrl, self.appKey, self.usr, self.passwd = serviceUrl, appKey, usr, passwd
self.server = xmlrpclib.ServerProxy(self.serviceUrl)
def newPost(self, title='Title used for test', description='this is a test post.', category='no category', publish=True, blogid='', **kw):
return self.server.MetaWeblog.newPost(blogid, self.usr, self.passwd, dict(kw, title=title, description=description, category=category), publish)
.....
serviceUrl, appKey = 'http://www.cnblogs.com/ans42/services/MetaWeblog.aspx', 'ans42'
usr, passwd = 'ans42', 'xxxxxx'
blog = MetaWeblog(serviceUrl, appKey, usr, passwd)
print blog.newPost('Title', 'content')