Wordpress XMLRPC::Client.new()

February 18, 2007 by pedro mota

… when coding switter, using lot’s of command line, vim, bash, i felt the need to blog from vim. Some readings (quite a few availlable, actually) later, i was testing Wordpress xmlrpc using MovableType (Six Apart) calls to it. Vim allows ruby scripts (when compiled with that directive) use to create new commands, just like with python, perl, etc. So a bit of ruby code that may be handy: wordpress xmlrpc methods availability:\r\n\r\nrequire ‘xmlrpc/client.rb’\r\n\r\nblog = XMLRPC::Client.new(\“your.blog.domain\“, \“/xmlrpc.php\“, 80)\r\nbegin\r\n   puts \“10 most recent post titles:\”\r\n   resp = blog.call(\“mt.getRecentPostTitles\“, 0, \“log\“, \“pwd\“, 10 )\r\n   puts resp\r\n   puts \“available rpc’s:\”\r\n   resp = blog.call(\“mt.supportedMethods\“, 0, \“log\“, \“pwd\” )\r\n   puts resp\r\nrescue XMLRPC::FaultException => e\r\n   puts \“ERROR: Code: #{e.faultCode}\”\r\n   puts \“ERROR: Msg.: #{e.faultString}\”\r\nend\r\n\r\nEmbebded example for the blog last 10 posts too.\r\nVery handy to make it work fast:\r\n- get the source code for wordpress xmlrpc.php;\r\n- get the source code for ruby xmlrpc/client.rb lib.\r\nAnalyze them well. All the answers are there. Screenshot for all this.

© 2018 | Follow on Twitter | pedro mg & Hugo