|
@@ -66,10 +66,10 @@ type AdData struct {
|
66
|
66
|
TargetAddition []AdAction `json:"target_addition,omitempty"`
|
67
|
67
|
Target string `json:"target,omitempty"`
|
68
|
68
|
ImageUrl string `json:"image_url,omitempty"`
|
69
|
|
- Duration int64 `json:"duration"`
|
|
69
|
+ Duration int64 `json:"duration,omitempty"`
|
70
|
70
|
VideoUrl string `json:"video_url,omitempty"`
|
71
|
71
|
JsOrderId int64 `json:"js_order_id,omitempty"`
|
72
|
|
- UserAgent string `json:"user_agent, omitempty"`
|
|
72
|
+ UserAgent string `json:"user_agent,omitempty"`
|
73
|
73
|
DpReport string `json:"dp_report,omitempty"`
|
74
|
74
|
Dp string `json:"dp,omitempty"`
|
75
|
75
|
OrderName string `json:"order_name,omitempty"`
|
|
@@ -112,19 +112,17 @@ func GetAdsInfos(dsp *utils.DspParam, advertiser string) (*AdData, error) {
|
112
|
112
|
}
|
113
|
113
|
|
114
|
114
|
client := &http.Client{}
|
115
|
|
- fmt.Printf("req url: %s\n", reqUrl)
|
|
115
|
+ log.WithField("request_id", dsp.RequestId).Infof("req url: %s", reqUrl)
|
116
|
116
|
req, err := http.NewRequest("GET", reqUrl, nil)
|
117
|
117
|
if err != nil {
|
118
|
118
|
return nil, err
|
119
|
119
|
}
|
120
|
120
|
|
121
|
|
- req.Header.Set(",authority", "m.video.xiaomi.com")
|
122
|
|
- req.Header.Set(",method", "GET")
|
123
|
|
- req.Header.Set(",path", reqUrl[26:])
|
124
|
|
- req.Header.Set(",scheme", "https")
|
|
121
|
+ req.Header.Set("authority", "m.video.xiaomi.com")
|
|
122
|
+ req.Header.Set("method", "GET")
|
|
123
|
+ req.Header.Set("path", reqUrl[26:])
|
|
124
|
+ req.Header.Set("scheme", "https")
|
125
|
125
|
req.Header.Set("content-type", "application/json")
|
126
|
|
- req.Header.Set("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3")
|
127
|
|
- req.Header.Set("accept-encoding", "gzip, deflate, br")
|
128
|
126
|
req.Header.Set("accept-language", "zh-CN,zh;q=0.9")
|
129
|
127
|
req.Header.Set("cache-control", "max-age=0")
|
130
|
128
|
req.Header.Set("upgrade-insecure-requests", "1")
|
|
@@ -132,17 +130,22 @@ func GetAdsInfos(dsp *utils.DspParam, advertiser string) (*AdData, error) {
|
132
|
130
|
|
133
|
131
|
resp, err := client.Do(req)
|
134
|
132
|
if err != nil {
|
|
133
|
+ log.WithField("request_id", dsp.RequestId).Errorf("http failed: %s", err)
|
135
|
134
|
return nil, err
|
136
|
135
|
}
|
137
|
136
|
defer resp.Body.Close()
|
138
|
137
|
body, err := ioutil.ReadAll(resp.Body)
|
139
|
|
- fmt.Printf("rsp body: %s\n", body)
|
140
|
138
|
if err != nil {
|
|
139
|
+ log.WithField("request_id", dsp.RequestId).Errorf("read http body failed: %s", err)
|
141
|
140
|
return nil, err
|
142
|
141
|
}
|
|
142
|
+
|
|
143
|
+ log.WithField("request_id", dsp.RequestId).Infof("rsp: %s", string(body))
|
|
144
|
+
|
143
|
145
|
rsp := XiaoMiAdInfoRsp{}
|
144
|
|
- err = json.Unmarshal(body, &rsp)
|
|
146
|
+ err = json.Unmarshal([]byte(string(body)), &rsp)
|
145
|
147
|
if err != nil {
|
|
148
|
+ log.WithField("request_id", dsp.RequestId).Errorf("unmarshal http rsp failed: %s, rsp: %s", err, string(body))
|
146
|
149
|
return nil, err
|
147
|
150
|
}
|
148
|
151
|
|