iOS获取Prestashop Web服务问题(kCFErrorDomainCFNetwork错误-1012。)

时间:2013-03-31 13:42:01

标签: ios web-services nsurlconnection prestashop

我不明白这个错误。

如果有人可以帮助我弄清楚这种无限的误解,你会让我睡得更好;)

我仔细地跟着documentation,一切正常,直到我切换到iOS项目。

 http://263DE3VI7PY5KE6O6R84RACYYEH5S5GF@192.168.1.112/prestashop/api/

enter image description here

从iOS方面我得到了这段代码和错误:

enter image description here

NSString *requestString = [NSString stringWithFormat:@"http://%@@%@/prestashop/api/", self.session.key, @"192.168.1.112"];

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:requestString]];

    [request setHTTPMethod:@"GET"];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *res, NSData *data, NSError *err){
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

        NSLog(@"%@", err);
        [self didReceiveData:data];
    }];

这里的所有代码都非常基础,可能太多了? 我是否忘记了从Web服务获取数据的一步?

2 个答案:

答案 0 :(得分:1)

NSString *requestString = [NSString stringWithFormat:@"http://%@:@%@/prestashop/api/", self.session.key, @"192.168.1.112"];

解决了,它错过了“:”:)

答案 1 :(得分:0)

当我使用curl时,我得到:

curl -X GET -u '263DE3VI7PY5KE6O6R84RACYYEH5S5GF:' 'http://192.168.1.112/prestashop/api/customers/'
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<customers>
<customer id="1" xlink:href="http://192.168.1.112/prestashop/api/customers/1"/>
<customer id="2" xlink:href="http://192.168.1.112/prestashop/api/customers/2"/>
</customers>
</prestashop>