本文整理汇总了Python中wordpress_xmlrpc.WordPressPost.author方法的典型用法代码示例。如果您正苦于以下问题:Python WordPressPost.author方法的具体用法?Python WordPressPost.author怎么用?Python WordPressPost.author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wordpress_xmlrpc.WordPressPost
的用法示例。
在下文中一共展示了WordPressPost.author方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_post
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import author [as 别名]
def create_post(title, text="", url="", image_url=""):
shortened_url = shorten_link(url) if url else ""
url_html = "<a href='{shortened_url}'>{url}</a><br/>".format(url=url, shortened_url=shortened_url) if url else ""
image_html = "<img style='width: 100%; height: auto;' src='{image_url}'></img><br/>".format(image_url=image_url) if image_url else ""
text_html = "<p>" + text + "</p>" + "<br/>" if text else ""
content = url_html + image_html + text_html
# https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/new/
# http://python-wordpress-xmlrpc.readthedocs.org/en/latest/examples/posts.html
post = WordPressPost()
post.title = title
post.content = content
post.author = "testaccount"
post.post_status = "publish"
# post.terms_names = {
# 'post_tag': ['test', 'firstpost'],
# 'category': ['Introductions', 'Tests']
# }
try:
redditsync.wordpress.wp.call(NewPost(post))
except Exception as err:
logging.error(str(err))
sys.exit()