I have a simple task, send one variable to a php page via GET. Nothing I seem to find works, and all are seemingly more than I need.
It seems I need code to set NSURL string, NSURL request, then execute.
Can someone perhaps paste me some simple code to just execute a URL like this:
http://localhost/trendypieces/site/ios/processLatest.php?caption=yosa
Thanks!
Here's the most current iteration of something that doesn't work, seems closer though as it actually throws back the error alert. Dunno what that error is...but....
//construct an URL for your script, containing the encoded text for parameter value
NSURL* url = [NSURL URLWithString:
[NSString stringWithFormat:
@"http://localhost/trendypieces/site/ios/processLatest.php?caption=yosa"]];
NSData *dataURL = [NSData dataWithContentsOfURL:url];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
if([serverOutput isEqualToString:@"OK"]) {
alertsuccess = [[UIAlertView alloc] initWithTitle:@"Posted" message:@"Done"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
} else {
alertsuccess = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Done"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
}
[alertsuccess show];
POSTrequest with parameters in the URL (which is wrong, it should be in the body). But this question is about adding parameters to aGETrequest, and if he really wanted to doGETit has to be in the URL, not the body, precisely the opposite scenario as suggested by that other question. I suspect the problem here may be the fact that he's starting connection two times, or something else. But not because he didn't put the parameters in the body.