【问题标题】:Python blogging, wordpress_xmlrpc doesn’t ‘publish’Python 博客,wordpress_xmlrpc 不“发布”
【发布时间】:2015-02-17 06:50:55
【问题描述】:

我正在尝试 Python wordpress_xmlrpc 文档中的行,http://python-wordpress-xmlrpc.readthedocs.org/en/latest/overview.html

这是我所拥有的:

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'

问题是它只是将草稿添加到博客,并没有将其作为新帖子发布到博客。

它有什么问题,我该如何纠正?谢谢。

【问题讨论】:

  • 您是否尝试在调用 wp.call(NewPost(post)) 之前放置 post.post_status = 'publish'?
  • @Furkan Omay,你真是个天才!你介意把它作为答案让我选择吗?
  • 我做了 :) 我想它解决了你的问题。
  • @Furkan Omay,太棒了!

标签: python xml-rpc


【解决方案1】:

根据official documentation,帖子默认以草稿形式发送。

在这里,您修改了 WordPressPost 对象的 post_status 属性您将该帖子发送到服务器之后。因此,它只在本地内存中发生了变化,服务器看不到变化。

简单地说

post.post_status = 'publish'

在您拨打电话之前 wp.call(NewPost(post)) 将使其按您想要的方式工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多