to be more specific, this is what I need to do in objective c, what is the equivalent for this?
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL,"api.example.com");
curl_setopt($ch, CURLOPT_POSTFIELDS, "a message to the site");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"GET" );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: Application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
What about using a NSURLRequest
and NSURLConnection
.
NSURLRequest
: you can init it with an URL, set the POST variables as HTTP Body, be sure the set the head correctly (eg: google for an example).
Then load the NSURLRequest
with an NSURLConnection
, even asynchronous as synchronous as you want.
See Append data to a POST NSURLRequest and iPhone sending POST with NSURLConnection