我有一个非常多样化的脚本,它在目标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"];
但代码不能以另一种方式工作。。。为什么?
试试这个:
NSString *urlString = [NSString stringWithFormat:@"http://www.webprogramming360.com/VideoPush/plist/urlTrans.php?videoID=%i", [result intValue]];