简体   繁体   中英

Wordpress post status published with xmlrpc lib

I'm trying to publish posts via xmlrpc lib with Python. The problem is in post status: it setted to "publish in future" but should to be "published". Here is a part of my code:

status_draft = 0
status_published = 1
server = xmlrpclib.ServerProxy(wp_url)
title = titles.encode("utf-8")
content = text.encode("utf-8")
date_created = xmlrpclib.DateTime(datetime.datetime.today())
categories = ["News"]
tags = []
data = {'title': title, 'description': content, 'dateCreated': date_created, 'categories': categories, 'mt_keywords': tags}
post_id = server.metaWeblog.newPost(wp_blogid, wp_username, wp_password, data, status_published)

WP version is 3.5.1, Python 2.7

How can I solve this problem ?

I find out that the prblem was truely in dateCreated. The way to solve that issue is to set date_created time minus random time value.

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