Vizible’s Blog











{January 25, 2009}   Post WordPress entry with Python
import xmlrpclib

user = 'username'
passwd = 'password'
server = xmlrpclib.ServerProxy('http://vizible.wordpress.com/xmlrpc.php')

blog_id = 0
title = 'test title' 
content = 'test content, from python'

blog_content = { 'title' : title, 'description' : content }
categories = [{'categoryId' : 'programming', 'isPrimary' : 1}] 

post_id = int(server.metaWeblog.newPost(blog_id, user, passwd, blog_content,0))
server.mt.setPostCategories(post_id, user, passwd, categories) # not work
server.mt.publishPost(post_id, user, passwd)
|

Reference — http://www.blackbirdblog.it/programmazione/progetti/28

|



Alexwebmaster says:

Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru



sravan953 says:

Nice source code! :D



Carles says:

Thanks for your post, very interesting (I’ve based my script in your one)

For the categories:
a) You can get a list doing this:
result = server.metaWeblog.getCategories(blog_id, user, password)

for category in result:
print category
print

b) you need to pass the categoryId, not the name:
categories = [{"categoryId" : "16"}]

This is based on what I’ve understood of the xmlrpc.php



Leave a Reply

et cetera