gpt4 book ai didi

ios - 使用密码从URL提取数据

转载 作者:行者123 更新时间:2023-12-01 16:59:58 26 4
gpt4 key购买 nike

我想从以下URL中获取数据:http://webservices.ns.nl/ns-api-stations。此URL需要登录。如何将该登录名放入我的代码中?这段代码是我现在正在使用的代码。

-(void)fetchStationData {
//获取数据的方法

//First lets check wheater there is an internet connection and if the host is reachable
if(internetActive) {

//Internet is active

//Init the parser
parser = [[RSSParser alloc] init];

//Set he parser context
parser.context = context;

//The array to het the data from
NSURL *url = [NSURL URLWithString:@"http://webservices.ns.nl/ns-api-stations"];

//The XML elements to fetch
NSArray *elements = [[NSArray alloc] initWithObjects:@"naam",nil];

//The actual fetchin
[parser fetchStationItemsForUrl:url forElements:elements];

//Save the context ?
[context save:nil];

//Clean up
[elements release];

}

最佳答案

您尝试访问并获取某些数据的服务器需要某种身份验证才能允许它。.因此,在尝试发出get请求之前,您需要执行身份验证。因此,您需要知道他们正在使用哪种身份验证方法(例如Digest Auth),并且还需要用户名和密码。

另外,您需要使用HTTPRequest库。我建议您使用ASIHTTPRequest,这真的很简单。您还可以在从服务器发出请求之前使用ashthtttprequest库执行身份验证。

关于ios - 使用密码从URL提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8020930/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com