//网络请求字符串
NSString *urlString = @"";
//UTF-8转码
NSString *urlStr = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//创建请求对象
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"请求方式" URLString:urlStr parameters:nil error:nil];
//将token添加到请求头
[request addValue:token forHTTPHeaderField:@"Authorization"];
//创建一个新的队列
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
//发送异步请求,请求完以后返回的数据,通过completionHandler参数来调用
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
}];
将token添加到请求头中进行网络请求
最新推荐文章于 2024-07-24 14:23:19 发布