//获取设备号:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSString *urlStr = @"http://distribution.dev.juntest.com/web/index/wawajiTest?device_id=xxxxx";
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
// manager.requestSerializer = [AFJSONRequestSerializer serializer];
// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
NSString *userAgent = [manager.requestSerializer valueForHTTPHeaderField:@"User-Agent"];
userAgent = [userAgent stringByAppendingPathComponent:@"CUSTOM_PART"];
[manager.requestSerializer setValue:userAgent forHTTPHeaderField:@"User-Agent"];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript",@"*/*", nil];
[manager POST:urlStr parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:(NSJSONReadingMutableLeaves) error:nil];
NSLog(@"%@", dict);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@", error);
}];
其他电脑版本的User-Agent
[manager.requestSerializer setValue:@"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)" forHTTPHeaderField:@"User-Agent"];
IE8 on Windows 7
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)
64-bit IE on 64-bit Windows 7:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0)
32-bit IE on 64-bit Windows 7:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)