Question

I have been trying to access the pls file data from shoutcast for some testing but the response seems to be forbidden and I am getting 403 as response. here is the code

NSURL *myurl = [NSURL URLWithString:@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=9944"] ;

//Accept:*/*
NSMutableURLRequest *myrequest = [[NSMutableURLRequest alloc]initWithURL:myurl];
[myrequest setValue:@"*/*" forHTTPHeaderField:@"Accept"];

//NSURL *myurl = [NSURL URLWithString:@"http://www.google.com"];
NSURLConnection *theConnection = [[NSURLConnection alloc]initWithRequest:myrequest  delegate:self];

On the response, it was showing a 403 and no data is received. I tried to check the content-type and it was showing audio/x-scpls

Was it helpful?

Solution

In case of disallowing NSURLRequests, changing the submitted user agent should avoid the 403 response:

[myRequest setValue:userAgent forHTTPHeaderField:@"useragent"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top