Hello all, I am writing a mobile App involving creating a Blogger client. I have the APIs that I need but the problem is how to write the ruby code for making a post using the texts beeing provided as well as making comments. The texts are supplied via form input but I don't know how to write the ruby code to post the text. I will be very happy to recieve a response. Thanks all
+2
A:
From Net::HTTP documentation:
require 'net/http'
require 'uri'
#1: Simple POST
res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
{'q'=>'ruby', 'max'=>'50'})
puts res.body
Mladen Jablanović
2010-05-10 13:02:07
I am very much delighted for the prompt answer. Thanks a lot.I have an error message right here:Content-Type application/x-www-form-urlencoded is not a valid input type.please do you have any suggestion on how to go about it?
Godwin
2010-05-10 13:14:16
Not sure about the particular error you are getting, but I guess you need to POST an XML there, not key-value parameter pairs as above. In that case, you might take a look at instance method `post`: http://apidock.com/ruby/Net/HTTP/post
Mladen Jablanović
2010-05-10 15:30:40
Perhaps I should rephrase the question like this: I have been trying to post blogs to Blogger via the API provided for posting but the problem I have is how to write the ruby code for the http post that will be able to carry the texts and make the post. In the API, it is stated that one has to First, create an XML representation of the post to publish.Please I will delighted with a suggestion. This is the API that was provided: "http://www.blogger.com/feeds/blogID/posts/default"NB:sorry for duplicating the question initially
Godwin
2010-05-11 14:56:08