Created
August 31, 2015 21:31
-
-
Save solanoize/64f5a6dcae53b6694c02 to your computer and use it in GitHub Desktop.
Aplikasi Wordpress Easy Posting - Fitur Post - Coding Post New - https://trello.com/c/l3rI8X5w
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Menampilkan seluruh postingan | |
| # ----------------------------- | |
| from wordpress_xmlrpc import Client, WordPressPost | |
| from wordpress_xmlrpc.methods.posts import GetPosts | |
| import pprint | |
| # login | |
| wp_url = "https://yourblogname.wordpress.com/xmlrpc.php" | |
| wp_user = "usernamewp" | |
| wp_pass = "passwordwp" | |
| wp = Client(wp_url, wp_user, wp_pass) | |
| # show postingan | |
| post = WordPressPost() | |
| posts = wp.call(GetPosts(post)) | |
| post_details = {} | |
| post_details['posts'] = [] | |
| for i,p in enumerate(posts): | |
| post_details['posts'].append( { 'id': p.id, | |
| "title": p.title, | |
| 'type': p.post_type, | |
| 'categories': [], | |
| 'tags': [], | |
| }) | |
| if p.terms: | |
| for term in p.terms: | |
| if term.taxonomy == 'category': | |
| post_details['posts'][i]['categories'].append(term.name) | |
| else: | |
| post_details['posts'][i]['tags'].append(term.name) | |
| pprint.pprint(post_details) | |
| ''' Result Example : | |
| {'posts': [{'categories': ['cerita', 'cinta', 'coding'], | |
| 'id': '480', | |
| 'tags': ['coding', 'python', 'test', 'xmlrpc'], | |
| 'title': 'Title Example 2', | |
| 'type': 'post'}, | |
| {'categories': ['cerita', 'cinta', 'coding'], | |
| 'id': '478', | |
| 'tags': ['coding', 'python', 'test', 'xmlrpc'], | |
| 'title': 'Title Example 2', | |
| 'type': 'post'}, | |
| {'categories': ['Introduction', 'Test'], | |
| 'id': '476', | |
| 'tags': ['coding', 'python', 'test', 'xmlrpc'], | |
| 'title': 'Title Example 2', | |
| 'type': 'post'}, | |
| {'categories': ['Intro', 'Tester'], | |
| 'id': '474', | |
| 'tags': ['firstpost testing Python', 'test'], | |
| 'title': 'Testing RPC Python', | |
| 'type': 'post'}, | |
| {'categories': ['coding', 'python'], | |
| 'id': '438', | |
| 'tags': ['app', | |
| 'blog', | |
| 'coding', | |
| 'deploy', | |
| 'development', | |
| 'django', | |
| 'git', | |
| 'github', | |
| 'init', | |
| 'microblog', | |
| 'project', | |
| 'proyek', | |
| 'python', | |
| 'python34', | |
| 'pythonanywhere', | |
| 'server', | |
| 'web'], | |
| 'title': 'Deploy Django di Pythonanywhere', | |
| 'type': 'post'}]} | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment