English 中文(简体)
API HTTPOK 200 Postback handler from Ruby App
原标题:

I m building a sinatra Ruby app that interacts with Jambool Social Gold API (a virtual currency platform).

After a transaction is complete (the user purchases points) Jambool sends a "postback" to "foo.com/postback?signature=foo".

The API documentation says that it expects an OK response in the body of the postback (after I validate the transaction). I am not sure how to do this, is this for Net::Http class? This is what I ve tried so far:

get "/postback" do
    signature = params[:signature]
    if signature is valid
       # HTTP okay here
    else
       # error
    end
end

What is the API expecting as a successful response? and how do I generate it?

UPDATE: The solution is to use the HTTP verb POST and not GET:

post "/postback" do 
   "OK"
end
最佳回答

All you have to do is just send the string "OK" back in the response like so:

render_text "OK"

问题回答

I think in rails 2+ you would want that to be

render :text => "OK"




相关问题
How to set response filename without forcing "save as" dialog

I am returning a stream in some response setting the appropriate content-type header. The behavior I m looking for is this: If the browser is able to render content of the given content type then it ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Does HttpWebRequest send 200 OK automatically?

Background: I am implementing Paypal IPN handler. This great article on Paypal states that I am required to send a 200 OK back to Paypal after I read the response. The processing of IPN request is ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

Finding out where curl was redirected

I m using curl to make php send an http request to some website somewhere and have set CURLOPT_FOLLOWLOCATION to 1 so that it follows redirects. How then, can I find out where it was eventually ...

热门标签