Movable Type features a full implementation of the Blogger XML-RPC API (where
applicable). The only two methods that are not supported by Movable Type are
getTemplate
and setTemplate
, due to the differences between Blogger's
template system and Movable Type's template system.
Movable Type also supports the metaWeblog XML-RPC API (also where applicable).
Finally, Movable Type also adds a couple of other methods of its own for manipulating the categories assigned to your entries.
Usage of any of these XML-RPC APIs
requires that your webserver have both LWP::UserAgent
and SOAP::Lite
installed; if yours does not, the Installation Instructions can tell you how
to install them.
Following are the XML-RPC methods supported by Movable Type:
Parameters: String appkey, String blogid, String username, String password, String content, boolean publish
Return value: on success, String postid of new post; on failure, fault
Parameters: String appkey, String postid, String username, String password, String content, boolean publish
Return value: on success, boolean true value; on failure, fault
Parameters: String appkey, String postid, String username, String password, boolean publish
Return value: on success, boolean true value; on failure, fault
Parameters: String appkey, String blogid, String username, String password, int numberOfPosts
Return value: on success, array of structs containing ISO.8601 dateCreated, String userid, String postid, String content; on failure, fault
Notes: dateCreated is in the timezone of the weblog blogid
Parameters: String appkey, String username, String password
Return value: on success, array of structs containing String url, String blogid, String blogName; on failure, fault
Parameters: String appkey, String username, String password
Return value: on success, struct containing String userid, String firstname, String lastname, String nickname, String email, String url; on failure, fault
Notes: firstname is the Movable Type username up to the first space character, and lastname is the username after the first space character.
Parameters: String blogid, String username, String password, struct content, boolean publish
Return value: on success, String postid of new post; on failure, fault
Notes: the struct content can contain the following standard keys: title, for the title of the entry; description, for the body of the entry; and dateCreated, to set the created-on date of the entry. In addition, Movable Type's implementation allows you to pass in values for five other keys: int mt_allow_comments, the value for the allow_comments field; int mt_allow_pings, the value for the allow_pings field; String mt_convert_breaks, the value for the convert_breaks field; String mt_text_more, the value for the additional entry text; String mt_excerpt, the value for the excerpt field; String mt_keywords, the value for the keywords field; and array mt_tb_ping_urls, the list of TrackBack ping URLs for this entry. If specified, dateCreated should be in ISO.8601 format.
Parameters: String postid, String username, String password, struct content, boolean publish
Return value: on success, boolean true value; on failure, fault
Notes: the struct content can contain the following standard keys: title, for the title of the entry; description, for the body of the entry; and dateCreated, to set the created-on date of the entry. In addition, Movable Type's implementation allows you to pass in values for five other keys: int mt_allow_comments, the value for the allow_comments field; int mt_allow_pings, the value for the allow_pings field; String mt_convert_breaks, the value for the convert_breaks field; String mt_text_more, the value for the additional entry text; String mt_excerpt, the value for the excerpt field; String mt_keywords, the value for the keywords field; and array mt_tb_ping_urls, the list of TrackBack ping URLs for this entry. If specified, dateCreated should be in ISO.8601 format.
Parameters: String postid, String username, String password
Return value: on success, struct containing String userid, ISO.8601 dateCreated, String postid, String description, String title, String link, String permaLink, String mt_excerpt, String mt_text_more, int mt_allow_comments, int mt_allow_pings, String mt_convert_breaks, String mt_keywords; on failure, fault
Notes: link and permaLink are both the URL pointing to the archived post. The fields prefixed with mt_ are Movable Type extensions to the metaWeblog.getPost API.
Parameters: String blogid, String username, String password, int numberOfPosts
Return value: on success, array of structs containing ISO.8601 dateCreated, String userid, String postid, String description, String title, String link, String permaLink, String mt_excerpt, String mt_text_more, int mt_allow_comments, int mt_allow_pings, String mt_convert_breaks, String mt_keywords; on failure, fault
Notes: dateCreated is in the timezone of the weblog blogid; link and permaLink are the URL pointing to the archived post
Parameters: String blogid, String username, String password, struct file
Return value: URL to the uploaded file.
Notes: the struct file should contain two keys: base64 bits (the base64-encoded contents of the file) and String name (the name of the file). The type key (media type of the file) is currently ignored.
Parameters: String blogid, String username, String password, int numberOfPosts
Return value: on success, array of structs containing ISO.8601 dateCreated, String userid, String postid, String title; on failure, fault
Notes: dateCreated is in the timezone of the weblog blogid
Parameters: String blogid, String username, String password
Return value: on success, an array of structs containing String categoryId and String categoryName; on failure, fault.
Parameters: String postid, String username, String password
Return value: on success, an array of structs containing String categoryName, String categoryId, and boolean isPrimary; on failure, fault.
Notes: isPrimary denotes whether a category is the post's primary category.
Parameters: String postid, String username, String password, array categories
Return value: on success, boolean true value; on failure, fault
Notes: the array categories is an array of structs containing String categoryId and boolean isPrimary. Using isPrimary to set the primary category is optional--in the absence of this flag, the first struct in the array will be assigned the primary category for the post.
Parameters: none
Return value: an array of method names supported by the server.
Parameters: String postid
Return value: an array of structs containing String pingTitle (the title of the entry sent in the ping), String pingURL (the URL of the entry), and String pingIP (the IP address of the host that sent the ping).
Parameters: String postid, String username, String password
Return value: on success, boolean true value; on failure, fault
NOTE: the value of appkey
is ignored by Movable Type in all of the
Blogger XML-RPC methods.
You can use Movable Type's XML-RPC implementation with existing tools like w.bloggar, BlogApp, BlogLet, BlogBuddy, Jericho, etc. For example, to set up BlogBuddy to post to your Movable Type weblog, follow these instructions:
weblog(s)
using BlogBuddy's posting
interface.
The Movable Type code is written in an object-oriented style and contains a well-documented Perl API that you can use in your own Perl programs. The documentation itself is in POD format and is contained within the .pm files. You can read this documentation from the shell using the perldoc command. For example:
% cd <movable type directory>/lib % perldoc MT
Movable Type's plugin framework makes it easy to add new tags to the system. In the future, more callback functionality will be added.
Plugin files are Perl scripts placed in a special directory; when Movable Type is initalized, it loads all of the plugins, which can modify the Movable Type code and system at runtime. Only files with .pl extensions are considered plugins and loaded automatically.
Your plugins directory should be placed in the same directory as mt.cgi.
To create that directory, connect to your FTP server, and open the directory where you installed Movable Type. Create a new directory called plugins.
use MT::Template::Context; MT::Template::Context->add_tag(ServerUptime => sub { `uptime` }); 1;
Uptime: <$MTServerUptime$>
This is just a very simple example of a new tag that you can add. The plugin framework is not limited to adding tags that call system commands.
MT::Template::Context->add_container_tag(Loop => sub { my $ctx = shift; my $res = ''; my $builder = $ctx->stash('builder'); my $tokens = $ctx->stash('tokens'); for my $i (1..5) { $ctx->stash('i_value', $i); defined(my $out = $builder->build($ctx, $tokens)) or return $ctx->error($ctx->errstr); $res .= $out; } $res; }); MT::Template::Context->add_tag(LoopIValue => sub { my $ctx = shift; $ctx->stash('i_value'); });
It can be used like this in a template:
<MTLoop> The value of I is: <$MTLoopIValue$> </MTLoop>
And it will display:
The value of I is: 1 The value of I is: 2 The value of I is: 3 The value of I is: 4 The value of I is: 5
For example, the following will add 3 tags: <MTIfYes>
, which
always displays its contents; <MTIfNo>
, which never displays its
contents; and <MTEntryIfTitle>
, which must be used in entry
context, and which only displays its contents if the entry has a title.
use MT::Template::Context; MT::Template::Context->add_conditional_tag(IfYes => sub { 1 }); MT::Template::Context->add_conditional_tag(IfNo => sub { 0 }); MT::Template::Context->add_conditional_tag(EntryIfTitle => sub { my $e = $_[0]->stash('entry') or return; defined($e->title) && $e->title ne ''; });
These tags can be used like this:
<MTIfYes>Yes, this appears.</MTIfYes> <MTIfNo>No, this doesn't appear.</MTIfNo> <MTEntries> <MTEntryIfTitle> This entry has a title: <$MTEntryTitle$> </MTEntryIfTitle> </MTEntries>
MT::Template::Context->add_global_filter(rot13 => sub { (my $s = shift) =~ tr/a-zA-Z/n-za-mN-ZA-M/; $s; });
Which can be used like this:
<$MTEntryTitle rot13="1"$>
The anonymous subroutine is passed three arguments: the scalar value of the
tag to be filtered, the value of the argument supplied to the attribute, and
the MT::Template::Context object. As an example of the second argument,
if we invented a filter called foo
, and called it like this:
<$MTCommentAuthor foo="5"$>
the second argument to the callback routine would be 5
.
Plugin tags could be written to display RSS feeds, display server status information, implement a hit counter, etc. You can download plugins from http://www.movabletype.org/resources.shtml.