I want to fetch data from this URL: http://webservices.ns.nl/ns-api-stations. This URL requires a login. How to put this login in my code? This code is what I am using now.
-(void)fetchStationData {
//Method for the fetching of the data
//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];
}
The server which you try to access and fetch some data is requiring a some kind of authentication to allow it.. So before you try to make a get request you need the perform a authentication. So you need to know which kind of authentication method(for example Digest Auth) they’re using and also you need a username and password..
Also you need to use HTTPRequest library. I suggest you to use ASIHTTPRequest, It’s really simple.. You can also perform authentication with asihtttprequest library before make a request from a server.