我正在尝试使用python api发布到我的wordpress页面,立即发布帖子工作正常,但是当我试图安排帖子它不起作用时,发布日期是:1999/11/30
看起来我没有写出正确的日期模式。
这是我的代码:
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost
wp = Client('http://url.com/xmlrpc.php', 'username', 'password')
f = open('nm.txt','r')
cn = f.read()
post = WordPressPost()
post.title = "time stamp test"
post.content = cn
post.post_status = 'future'
post.date = '2012-02-14T11:22:34.593750Z';
wp.call(NewPost(post))
答案 0 :(得分:1)
您需要使用UTC格式作为日期属性。例如
from datetime import datetime
post.title = "woohhh!!!"
post.content = "blah blah blah"
post.date = datetime(2013, 11, 14, 20, 34, 2, 860000)
post.post_status = 'publish'