从Wordpress 3.5版本开始, xmlrpc默认开启, 更早期的版本可能在设置中手动开启. 以下是一个通过xmlrpc发布文章的脚本(python版本):
vim post.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import datetime, xmlrpclib
wp_url = "http://www.example.net/xmlrpc.php"
wp_username = "USER"
wp_password = "passwd"
wp_blogid = ""
status_draft = 0
status_published = 1
server = xmlrpclib.ServerProxy(wp_url)
title = "article title"
content = "article content"
#date_created = xmlrpclib.DateTime(datetime.datetime.strptime("2011-10-20 21:08", "%Y-%m-%d %H:%M"))
categories = ["Beijing"]
tags = ["sometag", "othertag"]
data = {'title': title, 'description': content, 'categories': categories, 'mt_keywords': tags}
post_id = server.metaWeblog.newPost(wp_blogid, wp_username, wp_password, data, status_published)
请注意: 如果脚本里的categories不存在, 则会把文章post到默认分为中.