Vizible’s Blog

Post WordPress entry with Python

Posted in Python by wearetherock on January 25, 2009
import xmlrpclib

user = 'username'
passwd = 'password'
server = xmlrpclib.ServerProxy('https://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

|

Advertisements
Tagged with: , ,

10 Responses

Subscribe to comments with RSS.

  1. Alexwebmaster said, on March 3, 2009 at 10:28 am

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

  2. sravan953 said, on August 24, 2009 at 1:05 pm

    Nice source code! 😀

  3. Carles said, on September 10, 2009 at 8:21 pm

    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

  4. post using python ^^ « sudo su - said, on August 3, 2010 at 4:23 pm

    […] post using python ^^ by risingtrigger on August 3, 2010 test content, from python source […]

  5. NoteCarver said, on October 11, 2011 at 1:14 am

    Make sure to use HTTPS in the URL to your blog, otherwise your password will be sent in plain-text over the network.
    Thanks for sharing this.

  6. denubis said, on November 8, 2011 at 4:43 am

    For what it’s worth, I used your script in my google shared items importer.

    http://denubis.wordpress.com/2011/11/07/some-notes-on-a-means-for-turning-a-shared-items-feed-from-reader-into-a-wordpress-blog/

  7. Vamsi Krishna said, on November 8, 2011 at 6:31 pm

    Hello.

    I was wondering if there is a way to tag the post. Also, is there a way to post in multiple categories ? I have tried executing the script with [{‘categoryId’ : “656, 832”}] (656, 832 are my category Ids).

    Thanks for the post. Nice work.

    • Vamsi Krishna said, on November 8, 2011 at 6:57 pm

      Oops! Did not realize it’s a list. All I have to do is [{‘categoryId’ : “656”}, {‘categoryId’ : “832”}].


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: