开发者

Putting together a valid NSMutableURLRequest using POST for TripIt webservice

Im trying to get TripIt OAuth authentication working, but I find the documentation to go a bit over my head. TripIt docs

The paragraph below is from the documentation, I have tried putting together a POST request for a SOAP service where the documentation specified what to put into the headers and how to build an xml for the Http body. In this case I have no idea on how to build my request. I have all the values the service asks for, just no idea of how to set these using only the info given below?

To obtain an authorized access token, POST the following request parameters to the URL: https://api.tripit.com/oauth/access_token

  • oauth_co开发者_StackOverflow社区nsumer_key: The Consumer's public key.
  • oauth_nonce: A nonce no more than 80 characters in length.
  • oauth_signature: The signature of the reque…
  • oauth_signature_method: Current supported methods are HMAC-SHA1.
  • oauth_timestamp: The timestamp in seconds since the epoch.
  • oauth_token: The request token obtained in Step 1.
  • oauth_token_secret: The request token secret obtained in Step 1.
  • oauth_version: OPTIONAL - Assumed to be '1.0'

Could someone help me with how I'll go about building the POST request from the above?

Thank you:)


The way to do it yourself would be to read up on how the body of a POST request is put together (it looks a lot like a URL query string), build the string out of the various parts, and then use the request's -setHTTPBody: method.

Most people recommend using ASIHTTPRequest, which, among many other things, will do that work for you. See, in particular, the ASIFormDataRequest class, and its -setPostValue:forKey: method.

Here's some more detail on the format of the POST body:

  • From the W3C HTML4 spec, the section on forms.
  • The Wikipedia entry on "percent escaping".
  • From the HTML5 spec draft. These rules should be backwards-compatible, while being more precise than the text in the HTML4 spec, but no promises.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜