Movable Type 特别(在可以使用的地方)加入了对 Blogger XML-RPC API 的完整支持。唯一不被 Movable Type 支持的两种方法分别是 getTemplate
和 setTemplate
;这是因为 Blogger 的模版系统和 Movable Type 的模版系统间有所差异所致。
Movable Type 同时也(在可以使用的地方)支持 metaWeblog XML-RPC API 。
最后, Movable Type 同时也增加了一些她自己的其它方法,用来操作指派到文章项目的类别。
要使用任何这些 XML-RPC API 前,都需要你的网页服务器先安装过 LWP::UserAgent
和 SOAP::Lite
才行。如果你还没有安装这些模块的话,安装指引可以教你如何安装他们。
下列是 Movable Type 所支持的 XML-RPC 方法:
参数: 字符串 appkey, 字符串 blogid, 字符串 username, 字符串 password, 字符串 content, 布林值 publish
传回值: 成功时为新发表文章的字符串 postid ;失败时为 fault
参数: 字符串 appkey, 字符串 postid, 字符串 username, 字符串 password, 字符串 content, 布林值 publish
传回值: 成功时为布林值 true ;失败时为 fault
参数: 字符串 appkey, 字符串 postid, 字符串 username, 字符串 password, 布林值 publish
传回值: 成功时为布林值 true ;失败时为 fault
参数: 字符串 appkey, 字符串 blogid, 字符串 username, 字符串 password, 整数 numberOfPosts
传回值: 成功时为包含有 ISO.8601 dateCreated, 字符串 userid, 字符串 postid, 字符串 content 结构的数组;失败时为 fault
请注意: dateCreated 会以网志 blogid 的时区来表示
参数: 字符串 appkey, 字符串 username, 字符串 password
传回值: 成功时为包含有字符串 url, 字符串 blogid, 字符串 blogName 结构的数组;失败时为 fault
参数: 字符串 appkey, 字符串 username, 字符串 password
传回值: 成功时为包含有字符串 userid, 字符串 firstname, 字符串 lastname, 字符串 nickname, 字符串 email, 字符串 url 的结构;失败时为 fault
请注意: firstname 是 Movable Type 的使用者名称中,第一个空白字符之前的部分;而 lastname 则是那个使用者名称中,第一个空白字符之后的部分。
参数: 字符串 blogid, 字符串 username, 字符串 password, 结构 content, 布林值 publish
传回值: 成功的时候为新文章的字符串 postid ;失败的时候为 fault
请注意: 结构 content 可以包含下列的标准键:文章项目的标题 title 、文章项目的本体 description 以及文章项目的写作日期 dateCreated 。除此之外,在 Movable Type 所植入的版本中,还能让你传递五个其它键的值:整数 mt_allow_comments 是 allow_comments 字段的值;整数 mt_allow_pings 是 allow_pings 字段的值;字符串 mt_convert_breaks 是 convert_breaks 字段的值;字符串 mt_text_more 是文章项目额外文字的值;字符串 mt_excerpt 是文摘字段的值;字符串 mt_keywords 是关键词字段的值;而数组 mt_tb_ping_urls 则是该文章项目引用通告网址的清单。如果加以指定的话, dateCreated 应该要是 ISO.8601 格式。
参数: 字符串 postid, 字符串 username, 字符串 password, 结构 content, 布林值 publish
传回值: 成功的时候为布林值 true 失败时为 fault
请注意: 结构 content 可以包含下列的标准键:文章项目的标题 title 、文章项目的本体 description 以及文章项目的写作日期 dateCreated 。除此之外,在 Movable Type 所植入的版本中,还能让你传递五个其它键的值:整数 mt_allow_comments 是 allow_comments 字段的值;整数 mt_allow_pings 是 allow_pings 字段的值;字符串 mt_convert_breaks 是 convert_breaks 字段的值;字符串 mt_text_more 是文章项目额外文字的值;字符串 mt_excerpt 是文摘字段的值;字符串 mt_keywords 是关键词字段的值;而数组 mt_tb_ping_urls 则是该文章项目的引用通告网址清单。如果加以指定的话, dateCreated 应该要是 ISO.8601 格式。
参数: 字符串 postid, 字符串 username, 字符串 password
传回值: 成功的时候为包含字符串 userid, ISO.8601 dateCreated, 字符串 postid, 字符串 description, 字符串 title, 字符串 link, 字符串 permaLink, 字符串 mt_excerpt, 字符串 mt_text_more, 整数 mt_allow_comments, 整数 mt_allow_pings, 字符串 mt_convert_breaks, 字符串 mt_keywords 的结构;失败时为 fault
请注意: link 和 permaLink 都是指到已汇编文章的网址;前置有 mt_ 的字段实际上是 Movable Type 的 metaWeblog.getPost API 扩展部分。
参数: 字符串 blogid, 字符串 username, 字符串 password, 整数 numberOfPosts
传回值: 成功的时候为包含 ISO.8601 dateCreated, 字符串 userid, 字符串 postid, 字符串 description, 字符串 title, 字符串 link, 字符串 permaLink, 字符串 mt_excerpt, 字符串 mt_text_more, 整数 mt_allow_comments, 整数 mt_allow_pings, 字符串 mt_convert_breaks, 字符串 mt_keywords 结构的数组;失败时为 fault
请注意: dateCreated 会以网志 blogid 的时区来表示; link 和 permaLink 都是指到已汇编文章的网址
参数: 字符串 blogid, 字符串 username, 字符串 password, 结构 file
传回值: 要上传档案用的网址。
请注意: 结构 file 应该要包含两个键: base64 bits (以 base64 编码过的档案内容)和字符串 name (档名)。 type 键(档案的媒体类别)目前会被忽略掉。
参数: 字符串 blogid, 字符串 username, 字符串 password, 整数 numberOfPosts
传回值: 成功的时候为包含 ISO.8601 dateCreated, 字符串 userid, 字符串 postid, 字符串 title 结构的数组;失败时为 fault
请注意: dateCreated 会以网志的时区 blogid 来表示
参数: 字符串 blogid, 字符串 username, 字符串 password
传回值: 成功的时候为包含字符串 categoryId 和字符串 categoryName 结构的数组;失败时为 fault
参数: 字符串 postid, 字符串 username, 字符串 password
传回值: 成功的时候为包含字符串 categoryName, 字符串 categoryId, and 布林值 isPrimary 结构的数组;失败时为 fault
请注意: isPrimary 代表某个类别是否为该文章的主要类别。
参数: 字符串 postid, 字符串 username, 字符串 password, 数组 categories
传回值: 成功的时候为布林值 true ;失败时为 fault
请注意: 数组 categories 是包含字符串 categoryId 和 布林值 isPrimary 结构的数组。你不一定要用 isPrimary 来设定主要类别 -- 没有这个旗标时,数组里的第一个结构会被指定成这篇文章的主要类别。
参数: 无
传回值: 服务器所支持的方法数组
参数: 无
传回值: 一个包含了字符串 key 和字符串 label 结构的数组。 key 是用来辨识某个文字格式外挂模块的独特字符串,而 label 则是用来让使用者读得懂的描述说明。 key 的值应该在 mt_convert_breaks 参数被送到 newPost 和 editPost 。
参数: 字符串 postid
传回值: 成功的时候为包含字符串 pingTitle (送出通告的文章项目标题), 字符串 pingURL (文章项目的网址)和字符串 pingIP (送出通告的主机 IP 地址)结构的数组。
参数: 字符串 postid, 字符串 username, 字符串 password
传回值: 成功的时候为布林值 true ;失败时为 fault
请注意: appkey
的值在所有的 Blogger XML-RPC 方法中都会被 Movable Type 所忽略。
你可以搭配既有的工具像是 w.bloggar, BlogApp, BlogLet, BlogBuddy, Jericho, 等等来使用 Movable Type 所装置的 XML-RPC 组件。举例来说,如果你想要用 BlogBuddy 在你的 Movable Type 网志上发表的话,你可以这么做:
网志
上发表文章了。
Movable Type 的程序码是由对象导向样式且包含妥善文件的 Perl API 所撰写而成的,因此你可以在你自己的 Perl 程序中加以取用。这些文件本身是以 POD 格式包含在 .pm 档案里的。你可以从 shell 使用 perldoc 命令来阅读这些文件。举例来说:
% cd <movable type 目录>/lib % perldoc MT
Movable Type 的外过模块网络使得在系统中增加新的卷标相当容易。未来还会加入更多回收功能。
外挂模块档案是被放在某个特定目录里的 Perl 脚本;当 Movable Type 启用的时候,它会加载所有的外挂模块,并且藉此在执行时期修改 Movable Type 的程序码和系统。祇有扩展名是 .pl 的档案才会被当成外挂模块而被自动地加载。
你的 plugins 目录应该跟 mt.cgi 被放在相同的目录里。
如果你要建立这个目录,首先连到你的 FTP 服务器上,并且开启你安装 Movable Type 的目录。然后建立一个叫 plugins 的目录。
use MT::Template::Context; MT::Template::Context->add_tag(ServerUptime => sub { `uptime` }); 1;
Uptime: <$MTServerUptime$>
这祇是一个增加新卷标的简单范例。事实上外挂模块网络并没有限定祇能增加会叫用系统命令的卷标。
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'); });
这可以被用在像是某个模版里:
<MTLoop> I 的值是: <$MTLoopIValue$> </MTLoop>
使用的效果会是:
I 的值是: 1 I 的值是: 2 I 的值是: 3 I 的值是: 4 I 的值是: 5
举例来说,下面这会增加 3 个卷标: <MTIfYes>
总是会显示其内容; <MTIfNo>
永远不会显示其内容 ;而 <MTEntryIfTitle>
一定得用于项目情境中,同时祇有当项目具有标题时才会显示其内容。
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 ''; });
这些卷标可以像这样用:
<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; });
可以像这样子用:
<$MTEntryTitle rot13="1"$>
匿名副例程会被递送三个参数:要被过滤的卷标的纯量值、属性会用到的参数值、以及 MT::Template::Context 对象。举一下第二个参数的范例;如果我们创造了一个叫做 foo
的滤器,然后像这样子加以叫用:
<$MTCommentAuthor foo="5"$>
对于收回例程来说,第二个参数会是 5
。
外挂模块卷标可以被写来显示 RSS 、显示服务器状态信息、或者是加入点击计数器之类的。你也可以从 http://www.movabletype.org/resources.shtml 下载别人写好的外挂模块。