简体   繁体   中英

Python blogging, wordpress_xmlrpc doesn’t ‘publish’

I am trying the lines in Python wordpress_xmlrpc documentation, http://python-wordpress-xmlrpc.readthedocs.org/en/latest/overview.html .

Here is what I have:

wp = Client('https://remembertochange.wordpress.com/xmlrpc.php', 'user', 'pass')
posts = wp.call(GetPosts())

post = WordPressPost()
post.title = 'My new title'
post.content = 'This is the body of my new post.'

post.terms_names = {
  'post_tag': ['test', 'firstpost'],
  'category': ['Introductions', 'Tests']
}

wp.call(NewPost(post))

post.post_status = 'publish'

The problem is it only adds a draft to the blog, and doesn't publish it as a new post to the blog.

What's wrong with it, and how can I correct it? Thanks.

According to official documentation , posts will be sent as drafts by default.

Here, you modify the post_status property of WordPressPost object after you sent that post to the server. Thus, it's only changed in local memory and server does not see the change.

Simply, putting

post.post_status = 'publish'

before you make the call wp.call(NewPost(post)) will make it work as the way you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM