...
|
...
|
@@ -11,6 +11,7 @@ |
|
|
#import "YH_Reachability.h"
|
|
|
#import "YHLog.h"
|
|
|
#import "NSData+YHERGZip.h"
|
|
|
#import "NSString+ER_URL.h"
|
|
|
|
|
|
#define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport"
|
|
|
|
...
|
...
|
@@ -52,12 +53,13 @@ |
|
|
if (!self.canUpload) {
|
|
|
return;
|
|
|
}
|
|
|
NSData *postData = [self getBodyData:parameters];
|
|
|
if (!postData) {
|
|
|
NSError *nullError = [[NSError alloc] initWithDomain:@"YoHoErrorDomain" code:-11111 userInfo:@{NSLocalizedDescriptionKey:@"data 不能为空!"}];
|
|
|
result(NO,nil,nullError);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
|
|
|
|
|
|
NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
NSString *parsStr = [[NSString stringWithFormat:@"_mlogs=%@",erSafeValue(parsJsonStr)]er_encodedString];
|
|
|
NSData* xmlData = [parsStr dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
NSData *postData = [xmlData YHERgzippedData];
|
|
|
|
|
|
[self.uploadEventRequest setHTTPBody:postData];
|
|
|
[self.uploadEventRequest setValue:(@(self.uploadEventRequest.HTTPBody.length)).description forHTTPHeaderField:@"Content-Length"];
|
...
|
...
|
@@ -95,7 +97,7 @@ |
|
|
result(YES,tag,nil);
|
|
|
}
|
|
|
}];
|
|
|
|
|
|
|
|
|
[task resume];
|
|
|
}
|
|
|
|
...
|
...
|
@@ -105,11 +107,10 @@ |
|
|
if (param == nil || [param isEqual:[NSNull null]]) {
|
|
|
return nil;
|
|
|
}
|
|
|
|
|
|
|
|
|
NSError *error;
|
|
|
|
|
|
NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error];
|
|
|
|
|
|
if (error) {
|
|
|
return nil;
|
|
|
}
|
...
|
...
|
@@ -131,7 +132,7 @@ |
|
|
if (!_uploadEventRequest) {
|
|
|
NSURL *url = [NSURL URLWithString:kYOHOEventReportURL];
|
|
|
_uploadEventRequest =[NSMutableURLRequest requestWithURL:url];
|
|
|
[_uploadEventRequest setValue:@"application/json" forHTTPHeaderField:@"content-type"];
|
|
|
[_uploadEventRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
|
|
|
_uploadEventRequest.HTTPMethod = @"POST";
|
|
|
[_uploadEventRequest setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
|
|
|
}
|
...
|
...
|
|