NSURL *url1 = [NSURL URLWithString:[webUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request=[[NSMutableURLRequest alloc]initWithURL:url1 cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:20];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"111318d2-b5a5-1998-be2a-30607d1591ca" forHTTPHeaderField:@"appid"];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:true];
if (conn) {
[conn start]; //发送请求
}
很重要的两句话记住了:就可以设置请求头