1

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

4

1 回答 1

3

在不允许 NSURLRequests 的情况下,更改提交的用户代理应该避免 403 响应:

[myRequest setValue:userAgent forHTTPHeaderField:@"useragent"];
于 2010-05-19T14:58:33.137 回答