test-wp2.py 694 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Test access to Wordpress
  2. #
  3. # Comment: Quite a usefull API to attach external scripts!!!
  4. #
  5. import sys
  6. from wordpress_xmlrpc import Client
  7. from wordpress_xmlrpc import WordPressPost, WordPressComment
  8. from wordpress_xmlrpc.methods.posts import GetPost
  9. from config import *
  10. # Access WP post
  11. # How to detector if it is available???
  12. # Use Wordpress account - not the mysql credentials
  13. # Todo: use scopus later !!!
  14. wp = Client(wp_api_url, wp_user, wp_password)
  15. wpid = 1149
  16. if len(sys.argv) > 1:
  17. wpid = int(sys.argv[1])
  18. # Read post
  19. try:
  20. post = wp.call(GetPost(wpid))
  21. print ("Post %d: %s" %(wpid,post.title))
  22. except:
  23. print ("Post %d seems to be not available" % wpid)