我们已经为此苦苦挣扎了一段时间。我正在尝试访问 iPhone 上的 REST api,并遇到了可以帮助我的 ASIHTTP 框架。所以我做了类似的事情
//call sites, so we can confirm username and password and site/sites
NSURL *url = [NSURL URLWithString: urlbase];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUsername:@"doronkatz%40xx.com" ];
[request setPassword:@"xxx"];
其中 urlbase
是 REST 站点的 URL。
现在,开发人员告诉我这个框架可能存在问题或错误,并且它没有正确传递 header 。是否有其他方法可以通过身份验证来测试或访问网络 REST 位置?
最佳答案
我建议查看 RestKit:http://restkit.org/它提供了一个出色的 API,用于访问 RESTful Web 服务并将远程资源表示为本地对象,包括将它们持久保存到 Core Data。开箱即用地支持 HTTP 身份验证。
关于iphone - Objective-C:在 iPhone 上访问 REST API 的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2264092/