Skip to content

Instantly share code, notes, and snippets.

@openkava
Forked from lleger/wp.rb
Created July 30, 2013 06:09
Show Gist options
  • Save openkava/6110608 to your computer and use it in GitHub Desktop.
Save openkava/6110608 to your computer and use it in GitHub Desktop.
require 'xmlrpc/client'
require 'pp'
class XMLRPC::Client
def set_debug
@http.set_debug_output($stderr);
end
end
module XMLRPCWorkAround
def do_rpc(request, async=false)
data = super
data.force_encoding("UTF-8")
data
end
end
connection = XMLRPC::Client.new('WEBSITE.com', '/xmlrpc.php')
# connection.set_debug
connection.extend(XMLRPCWorkAround)
begin
result = connection.call('blogger.getRecentPosts', 0, 0, 'ADMIN', 'PASSWORD', 10)
rescue XMLRPC::FaultException => e
puts e.faultString
end
pp result.first["dateCreated"].to_s
pp result.first["content"].match(/<title>(.*)<\/title>/)[1]
pp result.first["content"].match(/<category>(.*)<\/category>/)[1]
pp result.first["content"].gsub(/<title>(.*)<\/title>/, "").gsub(/<category>(.*)<\/category>/, "")
begin
result = connection.call('mt.getPostCategories', result.first["postid"], 'ADMIN', 'PASSWORD')
rescue XMLRPC::FaultException => e
puts e.faultString
end
pp result.first["categoryName"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment