嗨,我在向 PHP 发送 GET 请求时遇到问题,相同的 PHP 在 Web 浏览器中运行时工作正常这里是 PHP 和 Obj-C PHP 的代码片段
$var1=$_GET['value1'];
$var2=$_GET['value2'];
当我在像http://sample.com/sample.php?value1=hi&value2=welcome这样的浏览器中调用它时 ,它工作正常,但是从 obj ci 无法成功 obj C
NSString *url =[NSString stringWithFormat:@"http://sample.com/sample.php"];
NSData *data = [@"sample.php" dataUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",url);
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[req setHTTPMethod:@"GET"];
[req setHTTPBody:data];
NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:req delegate:self]autorelease];
[connection start];
请帮忙?