[英]Python blogging, wordpress_xmlrpc doesn’t ‘publish’
我正在嘗試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'
問題在於它僅將草稿添加到博客中,而不會將其作為新帖子發布到博客中。
它有什么問題,我該如何糾正? 謝謝。
根據官方文檔 ,默認情況下,帖子將作為草稿發送。
在此,您可以將該帖子發送到服務器后修改WordPressPost對象的post_status屬性。 因此,它僅在本地內存中更改,服務器看不到更改。
簡單來說,
post.post_status = 'publish'
在您撥打電話之前,wp.call(NewPost(post))將使其按您希望的方式工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.