// // APIPOPOPO.m // smartRhino // // Created by tederen on 2019/11/13. // Copyright © 2019 tederen. All rights reserved. // #import "APIPOPOPO.h" @implementation APIPOPOPO + (void)ApiPOPOPO{ [[HttpManager sharedHttpManager] POSTUrl:Host(@"/api/app/app-version/get-version") parameters: @{@"versionType":@1}success:^(id _Nonnull responseObject) { REMOVESHOW } failure:^(NSError * _Nonnull error) { REMOVESHOW }]; [self startRequestWithUrl:Host(@"/api/app/app-version/get-version") method:@"POST" params: @{@"versionType":@1}]; } + (void)startRequestWithUrl:(NSString *)url method:(NSString *)method params:(NSDictionary *)params{ NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:&error]; NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding]; AFURLSessionManager *manager = [[AFURLSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; NSMutableURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:method URLString:url parameters:nil error:nil]; request.timeoutInterval = 30; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; // manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/plain"]; [request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]]; [[manager dataTaskWithRequest:request uploadProgress:^(NSProgress * _Nonnull uploadProgress) { } downloadProgress:^(NSProgress * _Nonnull downloadProgress) { } completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { if (!error) { NSLog(@"Reply JOSN:%@",responseObject); }else{ NSLog(@"ERROR:%@,%@,%@",error,response,responseObject); } }] resume] ; } @end