发布数据,但GET方法json -ios

如何使用get方法在具有6个值和json格式的api链接上发布数据?

我真的很费力。 我这样做了几天。 是否最好有6个用于写入值的文本字段和一个用于指示发布数据的按钮?

看看我的代码,请帮忙。

-(IBAction)postDataPressed { NSString *urlString = @"http://192.168.18.8/apisample2/friendb.php?fm=jsn"; NSURL *url = [NSURL URLWithString:urlString]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; [request setPostValue:user.text forKey:@"un"]; [request setPostValue:pass.text forKey:@"pd"]; [request setPostValue:gender.text forKey:@"gd"]; [request setPostValue:age.text forKey:@"ag"]; [request setPostValue:status.text forKey:@"st"]; [request setPostValue:lookfor.text forKey:@"lf"]; [request setRequestMethod:@"GET"]; [request setCompletionBlock:^{ NSString *responseString = [request responseString]; NSLog(@"Response: %@", responseString); }]; [request setFailedBlock:^{ NSError *error = [request error]; NSLog(@"Error: %@", error.localizedDescription); }]; [request setDidFinishSelector:@selector(requestFinished:)]; [request setDidFailSelector:@selector(requestFailed:)]; [request startAsynchronous]; } 

我希望有人会帮忙。

 NSString *request_url = [NSString stringWithFormat: @"http://192.168.18.8/apisample2/friendb.php?fm=jsn&un=%@&pd=%@&gd=%@&ag=%@&st=%@&lf=%@", user.text, pass.text, gender.text, age.text,status.text,lookfor.text]; NSURL *url = [NSURL URLWithString:request_url]; ASIHttpRequest *request = [ASIHttpRequest requestWithURL:url]; request.delegate = self; .... 

HTTP Get方法只接受url中的数据,称为查询字符串,因此您必须自己构建查询字符串。