|
@@ -11,6 +11,7 @@ |
|
@@ -11,6 +11,7 @@ |
11
|
#import "YH_Reachability.h"
|
11
|
#import "YH_Reachability.h"
|
12
|
#import "YHLog.h"
|
12
|
#import "YHLog.h"
|
13
|
#import "NSData+YHERGZip.h"
|
13
|
#import "NSData+YHERGZip.h"
|
|
|
14
|
+#import "NSString+ER_URL.h"
|
14
|
|
15
|
|
15
|
#define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport"
|
16
|
#define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport"
|
16
|
|
17
|
|
|
@@ -52,12 +53,13 @@ |
|
@@ -52,12 +53,13 @@ |
52
|
if (!self.canUpload) {
|
53
|
if (!self.canUpload) {
|
53
|
return;
|
54
|
return;
|
54
|
}
|
55
|
}
|
55
|
- NSData *postData = [self getBodyData:parameters];
|
|
|
56
|
- if (!postData) {
|
|
|
57
|
- NSError *nullError = [[NSError alloc] initWithDomain:@"YoHoErrorDomain" code:-11111 userInfo:@{NSLocalizedDescriptionKey:@"data 不能为空!"}];
|
|
|
58
|
- result(NO,nil,nullError);
|
|
|
59
|
- return;
|
|
|
60
|
- }
|
56
|
+
|
|
|
57
|
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
|
|
|
58
|
+
|
|
|
59
|
+ NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
60
|
+ NSString *parsStr = [[NSString stringWithFormat:@"_mlogs=%@",erSafeValue(parsJsonStr)]er_encodedString];
|
|
|
61
|
+ NSData* xmlData = [parsStr dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
62
|
+ NSData *postData = [xmlData YHERgzippedData];
|
61
|
|
63
|
|
62
|
[self.uploadEventRequest setHTTPBody:postData];
|
64
|
[self.uploadEventRequest setHTTPBody:postData];
|
63
|
[self.uploadEventRequest setValue:(@(self.uploadEventRequest.HTTPBody.length)).description forHTTPHeaderField:@"Content-Length"];
|
65
|
[self.uploadEventRequest setValue:(@(self.uploadEventRequest.HTTPBody.length)).description forHTTPHeaderField:@"Content-Length"];
|
|
@@ -109,7 +111,6 @@ |
|
@@ -109,7 +111,6 @@ |
109
|
NSError *error;
|
111
|
NSError *error;
|
110
|
|
112
|
|
111
|
NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error];
|
113
|
NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error];
|
112
|
-
|
|
|
113
|
if (error) {
|
114
|
if (error) {
|
114
|
return nil;
|
115
|
return nil;
|
115
|
}
|
116
|
}
|
|
@@ -131,7 +132,7 @@ |
|
@@ -131,7 +132,7 @@ |
131
|
if (!_uploadEventRequest) {
|
132
|
if (!_uploadEventRequest) {
|
132
|
NSURL *url = [NSURL URLWithString:kYOHOEventReportURL];
|
133
|
NSURL *url = [NSURL URLWithString:kYOHOEventReportURL];
|
133
|
_uploadEventRequest =[NSMutableURLRequest requestWithURL:url];
|
134
|
_uploadEventRequest =[NSMutableURLRequest requestWithURL:url];
|
134
|
- [_uploadEventRequest setValue:@"application/json" forHTTPHeaderField:@"content-type"];
|
135
|
+ [_uploadEventRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
|
135
|
_uploadEventRequest.HTTPMethod = @"POST";
|
136
|
_uploadEventRequest.HTTPMethod = @"POST";
|
136
|
[_uploadEventRequest setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
|
137
|
[_uploadEventRequest setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
|
137
|
}
|
138
|
}
|