Created
July 8, 2015 02:45
-
-
Save sungys/738cd7c5b7537814e904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface HttpClient : AFHTTPRequestOperationManager | |
+ (HttpClient *)sharedClient { | |
static HttpClient *_sharedClient = nil; | |
_sharedClient = [[HttpClient alloc] initWithBaseURL:[NSURL URLWithString:kRequestURLString]]; | |
_sharedClient.responseSerializer.acceptableContentTypes = [_sharedClient.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"]; | |
AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments]; | |
[_sharedClient setResponseSerializer:responseSerializer]; | |
return _sharedClient; | |
} | |
+(void) postHttpRequest:(NSString *)method | |
withParam:(NSDictionary *)paramRequest | |
withSuccess:(HttpClientSuccessBlock)success | |
withFailure:(HttpClientFailureBlock)failure { | |
NSMutableDictionary *paramBase = [[NSMutableDictionary alloc]initWithDictionary:paramRequest]; | |
[[HttpClient sharedClient] POST:[[ApiClient sharedInstance] urlStringForApi:method] parameters:paramRequest success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"success"); | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
if (failure) { | |
NSLog(@"errorResult"); | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment