Wednesday, December 13, 2006

MovableType, XMLRPC, ATOM

Atom Api Spec:
http://www.atomenabled.org/developers/api/atom-api-spec.php

Typed Atom API:
http://www.sixapart.com/pronet/docs/typepad_atom_api

Six Apart Atom Centre:
http://www.sixapart.com/pronet/breese/atom.html
http://www.sixapart.com/developers/atom.html

Rss Vs Atom
http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared

Atom Api in Movable Types:
http://www.benhammersley.com/undocumented_features/atom_api_in_movable_type.html

Movable Type Developer Centre:
http://www.sixapart.com/developers/movabletype.html

XMLRPC:
http://www.xmlrpc.com/

Atom Api Urls
To get the list of services sens a get request on the following URL:
http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/

This will give you a response in a similar format as below. For each blog set up on the server similar informarion will be returned.

<feed xmlns="http://purl.org/atom/ns#">
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.post" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.feed" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.upload" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8/svc=upload" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.categories" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8/svc=categories" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="text/html" rel="alternate" href="http://www.YOURDOMAIN.com/blogs/main/" title="YOUR BLOG'S TITLE #8" />
</feed>


Each link returned in the response is actually a URL of another request. The response above gives us five different links for a blog which has an ID of 8. rel attrubute gives the information about the URL. The URL of the blog from where users can see it is given in the alternate link.

If you want to post something using the API then use the URL in the item which has "service.post" rel attribute
If you want to retrieve data using the API then use the URL in the item which has "service.feed" rel attribute
To get the blog data:
http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8
As a default it will be returning the blog and its most recent 20 posts. The data is returned in a feed node having posts in entry tags. To diffrentiate the published and unpublisged posts, check the draft nodes inside each entries. If the entry is not published this node exists and its value becomes 'true'. If the entry is published, you may not be able to find it in the server's response.
Everything has a URL in Atom Api.
To get a specific post's data with the ID of 80 send a GET request on the following URL.
http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8/entryid=80
The data will be returned in one entry node.
To get the list of categories:
If you want to retrieve the list of categories using the API then use the URL in the item which has "service.categories" rel attribute.

While the username and password is sent in plain text using xmlrpc, it has to be sent encrypted in Atom Api. They do not use the logon password which you use it to logon to Movabletype. If you scroll down to Password section and to the bottom, you will see another password which is called "web services password". You will be using this password in both Apis and your username as you logon to Movabletype. Another problem is, instead of Author's display name, the username is returned inside an Entry node in Atom Api. It also returns the url and the email of the author. But in XmlRpc, there is no way to get the user details. You can only retrieve the details by providing the user's username and password. The other problem is, it returns the id, not even the username!! In XmlRpc there us no option to filter the unpublished posts. While it is very easy to get the most recent posts using XmlRpc, I could not find a way using Atom Api. Working on it!!!

If you want to implement those APIs, start by looking to Atomizer and xml-rpc.net Both are written in C# and working with Movabletypes.


To get the list of APIs that are supported by your blog server:

This link explains howto do it.

http://www.sixapart.com/pronet/breese/atom/protocol/atom_autodiscovery.html

View the source of your weblog's homepage.
In the of the HTML document, look for a link relation entitled "EditURI." It should look very similar to:
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.yourdomain.com/rsd.xml">
Cut and paste the value of the href attribute into your browser. This is the URL of the autodisovery document and contains a list of the APIs supported by the corresponding weblog.

To view your blog in atom format.
http://BLOGURL/atom.xml

To view your blog in rss format.
http://BLOGURL/index.xml

No comments: