Objective c 在objective c中使用CURL发送数据

Objective c 在objective c中使用CURL发送数据,objective-c,xcode,Objective C,Xcode,如何在objective c中使用下面的CURL命令 curl-d lang=fr-d badge=0 提前感谢您可以尝试: NSURL *url = [NSURL URLWithString:@"http://www.redis.com/subscriber/J8lHY4X1XkU"]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; NSString* str = @"lang=fr&badg

如何在objective c中使用下面的CURL命令

curl-d lang=fr-d badge=0

提前感谢

您可以尝试:

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];

有关这方面的更多信息,您可以在iOS文档中找到:

您可以尝试以下代码吗

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];

谢谢你…它对我有用。。。。。。。。。