Ruby, WordPress: reading the most recent posts

Having read the WordPress docs, and done some research, it seems as if the advice on how to get the last 10 posts on a WordPress site, is to do the following:

require 'xmlrpc/client'
#initialize a connection
connection = XMLRPC::Client.new2('')
result ='metaWeblog.getRecentPosts', 1,'admin','123456')
#or it seems that I can also call:
result ='wp.getPages', 1,'admin','123456',10)

Following the connection call, I get a legitimate result:

 => #<XMLRPC::Client:0x007fdfec50cac0 @http_header_extra=nil, @http_last_response=nil, @cookie=nil, @host="", @path="/RPC2", @proxy_host=nil, @proxy_port=nil, @use_ssl=false, @timeout=30, @port=80, @password=nil, @user=nil, @auth=nil, @http=#<Net::HTTP open=false>, @parser=nil, @create=nil> 

But when I do:

result ='wp.getPages', 1,'admin','123456',10)


result ='metaWeblog.getRecentPosts', 1,'admin','123456')

I get:

SocketError: getaddrinfo: nodename nor servname provided, or not known

Any ideas?


Actually I was having the same error message when trying to post from my Sinatra app with the xmlrpc/client.

The interesting is, when I used the same way of posting from IRB, I could successfully post to my blog.

I found out that it seems xmlrpc does not really like the protocol. I removed the


from the link and it went without a hitch. Give it a try, maybe helps.

Need Your Help

Add two price for same item at codeigniter

php codeigniter session cart

i want to add two price for same item in codeigniter. But there is available for add only one price at codeigniter cart function. i need to insert INR price and USD price separate. how can i do thi...

Accessing contact information of a facebook app user

facebook facebook-graph-api

I have access_token for facebook application. Is there a way I can get the contact information(phone-number) of the user of my facebook application?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.