test-wp2.py 698 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. # Access WP post
  10. # How to detector if it is available???
  11. # Use Wordpress account - not the mysql credentials
  12. # Todo: use scopus later !!!
  13. wp = Client('http://localhost/~kopmann/ufo2/xmlrpc.php', 'ufo', '$ipepdv$')
  14. wpid = 1149
  15. if len(sys.argv) > 1:
  16. wpid = int(sys.argv[1])
  17. # Read post
  18. try:
  19. post = wp.call(GetPost(wpid))
  20. print "Post %d: %s" %(wpid,post.title)
  21. except:
  22. print "Post %d seems to be not available" % wpid