Posting ke Wordpress Menggunakan Python Wordpress XMLRPC

Berikut code snippet untuk melakukan posting ke WP:
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
from wordpress_xmlrpc.methods.users import GetUserInfo
from wordpress_xmlrpc.methods import posts


wp = Client("http://localhost/xmlrpc.php", "admin", "admin")
# posts = wp.call(GetPosts())
# print(posts)
# users = wp.call(GetUserInfo())
# print(users)

post = WordPressPost()
post.title = "My new python title"
post.content = "This is the body of my new post."
post.terms_names = {
"post_tag": ["test", "firstpost"],
"category": ["Introductions", "Tests"]
}
post.id = wp.call(NewPost(post))

post.post_status = "publish"
wp.call(posts.EditPost(post.id, post))

Kenapa wordpress? Karena platform ini terkenal SEO friendly.. Tinggal bagaimana kreativitas kita aja...

Comments

Popular posts from this blog

Kisah Nabi Uzair a.s.

Adding Image Alternate Text into WordPress Image Attachment using python-wordpress-xmlrpc Library

Hikayat Penjual Madu dan Penjual Cuka