views:

13

answers:

0

How my rails app can handle the incoming headers of a request like:

curl -v -H 'X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json' -H 'X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/",    
oauth_consumer_key="yTrEIQH6jhtmLUypg8T5", oauth_signature_method="HMAC-SHA1",    
oauth_token="514797-YuI8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWTyu",oauth_timestamp="1271323750",
oauth_nonce="oYu6nMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7U9Y", 
oauth_version="1.0", oauth_signature="CV4bTfE7Rs9J1kafTGwufLJdspo%3D"' -F "file=@/path/to/file" http://localhost:3000/api/upload.xml

How can my app send this header to twitter by calling verify_credentials.json and how can handle the response (if twitter answer correctly or not) in order to continue?

UPDATE: currently in my api controller i have a simply def upload that the request comes and looks like:

def upload
        file = File.new
        file.file = params[:file]
        # ... extra code

        respond_to do |format|
            if file.save                
                format.xml  { render :xml => file, :status => :created, :location => file }

            else
                format.xml  { render :xml => file.errors, :status => :unprocessable_entity }    
            end
        end
     end

How can i handle the header?

Thanks in advance!