1

我有一个非常多样化的脚本,可以在目标 c 中进行 GET http 调用,但作为回报,我在服务器端收到 403 Forbidden 错误...

我的目标c代码...

NSString *result = (__bridge NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)videoURL, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8);


NSString *urlString = [NSString stringWithFormat:@"http://www.webprogramming360.com/VideoPush/plist/urlTrans.php?videoID=%@",result];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
NSURLConnection *connect = [[NSURLConnection alloc] initWithRequest:request delegate:self];

if(connect) {
    NSLog(@"Successful!  =----= %d",[result length]);
} else {
    NSLog(@"Failure");
}

这非常简单,如果将 urlString 对象更改为此,它实际上可以工作......

NSString *urlString = [NSString stringWithFormat:@"http://www.webprogramming360.com/VideoPush/plist/urlTrans.php?videoID=1"];

但是代码不能以其他方式工作......为什么?

4

1 回答 1

1

试试这个:

NSString *urlString = [NSString stringWithFormat:@"http://www.webprogramming360.com/VideoPush/plist/urlTrans.php?videoID=%i", [result intValue]];
于 2012-07-16T00:50:44.837 回答