AFNetworking 2.5: How to get information from php
I am a NOOB when it comes to using AFNetworking and I am facing some problems. I have a simple php script that echoes "hello world" and I would like to access the data for use on iOS (using Xcode-beta 7). I have imported files (AFNetowrking and UIKit + AFNetworking) into my project as well as a .h file.
When I access the php script through my web browser, the response is printed, but when using the Get method provided in the AFNetworking docs, I keep getting the error ...
2015-07-10 12: 22: 46.553 TestPhp [2187: 53179] Error: Domain error = NSURLErrorDomain Code = -1001 "Request timed out." UserInfo = 0x7ff99062b240 {NSUnderlyingError = 0x7ff990718610 "Request timed out.", NSErrorFailingURLStringKey = https: //myServer.example. com / connect.php , NSErrorFailingURLKey = https://myServer.example.com/connect.php , _kCFStreamErrorDomainKey = 4, _kCFStreamErrorCodeKey = -2102, NSLocalizedDescription = Request timed out.}
My php file named "connect" looks like this:
<?php echo json_encode(@"Hello World"); ?>
I am calling AFNetworking parameters in my viewDidLoad method in Xcode to print to the console. this method looks like this ...
- (void)viewDidLoad {
[super viewDidLoad];
//[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://ios.rcptfit.com/connect.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
Any help would be greatly appreciated!
source to share
No one has answered this question yet
Check out similar questions: