Atif Azad
Atif Azad

Reputation: 1294

how to make cURL call in Objective C?

Please any one help to make cURL call of below url

curl -u "demo:demo" -H "Accept: application/json" http://api.holdsport.dk/v1/teams

it would really helpful for me to continue my project. demo:demo is username and password

Thanks.

Upvotes: 2

Views: 3029

Answers (2)

jbat100
jbat100

Reputation: 16827

The libcurl project which cURL is based on is C based and will run perfectly fine as C is an Objective-C subset (many examples here). Although if you are targeting Cocoa/Cocoa Touch only, then the NSURLConnection classes (or higher-level ASIHTTPRequest or AFNetworking third party libraries) would be very much easier (with asynchronous handling out of the box).

EDIT: Actually if you really want to use cURL, there are Cocoa bindings for it.

Upvotes: 3

Kristian
Kristian

Reputation: 21830

This is how I've seen http requests made

//Create a new url request with our url path
myRequest_ = [[ASIHTTPRequest alloc]initWithURL:[NSURL URLWithString:URL_PATH]];
myRequest_.delegate = self;

//send out the request as asynchronous
[myRequest_ startAsynchronous];

http://www.roostersoftstudios.com/2011/10/16/iphone-dev-how-to-communicate-with-server-using-http-json-and-phpor-any-server-side-language/

Upvotes: 0

Related Questions