代码之家  ›  专栏  ›  技术社区  ›  Nareshkumar

应该禁止iPhone编程吗?

  •  1
  • Nareshkumar  · 技术社区  · 15 年前

    我一直试图从Shoutcast访问PLS文件数据进行一些测试,但响应似乎被禁止,我得到403作为响应。 这是密码 <代码> >/P>

    nsurl*myurl=[nsurl urlwithstring:@“http://yp.shoutcast.com/sbin/tunein-station.pls?ID=9944”];
    
    //接受:*/*
    nsmutableurlRequest*myRequest=[[nsmutableurlRequest alloc]initWithURL:myURL];
    [MyRequest设置值:@“*/*”ForHttpHeaderField:@“接受”];
    
    //nsurl*myurl=[nsurl urlwithstring:@“http://www.google.com”];
    nsurlconnection*theconnection=[[nsurlconnection alloc]initwithrequest:myrequest delegate:self];
    < /代码> 
    
    

    在响应中,它显示403,未接收到任何数据。我试图检查内容类型,它显示音频/X-SCPLS 有人能帮我解决这个问题吗?

    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];
    

    在响应中,它显示403,未接收到任何数据。我试图检查内容类型,它显示音频/X-SCPLS 有人能帮我解决这个问题吗?

    1 回复  |  直到 15 年前
        1
  •  3
  •   cem    15 年前

    如果不允许nsurlrequests,则更改提交的用户代理应避免403响应:

    [myRequest setValue:userAgent forHTTPHeaderField:@"useragent"];