-2

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);
Cœur
  • 37,241
  • 25
  • 195
  • 267
Dima
  • 11

1 Answers1

0

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

Community
  • 1
  • 1
Jelle De Laender
  • 577
  • 3
  • 16
  • i tried this for over a week now, im still getting an empty string in the post on the server side – Dima Apr 04 '12 at 06:40