-1

how i have to use the following CURL command in objective c,

curl -d lang=fr -d badge=0 http://www.redis.com/subscriber/J8lHY4X1XkU

Thanks in advance

user2215225
  • 11
  • 1
  • 3
  • 1
    http://stackoverflow.com/questions/2346893/tutorials-for-using-http-post-and-get-on-the-iphone-in-objective-c – kovpas Apr 16 '13 at 10:31

2 Answers2

3

You could try:

NSURL *url = [NSURL URLWithString:@"http://www.redis.com/subscriber/J8lHY4X1XkU"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];

NSString* str = @"lang=fr&badge=0";
NSData* body = [str dataUsingEncoding:NSUTF8StringEncoding];

[req setHTTPMethod:@"POST"];
[req setHTTPBody:body];
[req setValue:[NSString stringWithFormat:@"%d", [str length]] forHTTPHeaderField:@"Content-length"];

[[NSURLConnection alloc] initWithRequest:req delegate:self];

More about this you can find on iOS documentation: NSURLConnection and NSMutableURLRequest

alexcristea
  • 2,316
  • 16
  • 18
0

Can you try following code?

NSURL *url = [NSURL URLWithString:@"http://www.redis.com/subscriber/J8lHY4X1XkU?lang=fr&badge=0"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120];
[request setURL:url];
[request setHTTPMethod:@"GET"];
NSData *responce = [NSURLConnection  sendSynchronousRequest:request returningResponse:NULL error:NULL];
Sunil Zalavadiya
  • 1,993
  • 25
  • 36