So senden Sie eine GEt-Anfrage an PHP unter iOS

Hallo, ich habe ein Problem beim Senden einer GET-Anfrage an ein PHP. Dasselbe PHP funktioniert einwandfrei, wenn es im Webbrowser ausgeführt wird. Hier sind die Codeausschnitte von PHP und Obj-C PHP

$var1=$_GET['value1'];
$var2=$_GET['value2'];

wenn ich das im browser wie aufrufehttp://sample.com/sample.php?value1=hi&value2=welcome es funktioniert gut, aber von obj c konnte ich nicht erfolgreich sein 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];

Bitte helfen Sie?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage