how can i use the get method to post data on an api link with 6 values and a json format?
im really fuzzled. im doing this for days . is it best to have 6 textfields that will be used to write the value and a button to indicate post data?
check out my code and please help.
-(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];
}
i hope someone will help.
HTTP Get method only accept data in url, called query string, so you have to build query string yourself.