|
|
@@ -8,10 +8,13 @@ import com.fs.newAdv.domain.SiteStatistics;
|
|
|
import com.fs.newAdv.enums.AdvertiserTypeEnum;
|
|
|
import com.fs.newAdv.integration.client.AbstractApiClient;
|
|
|
import com.fs.common.constant.SystemConstant;
|
|
|
+import com.google.common.hash.Hashing;
|
|
|
+import com.google.common.io.BaseEncoding;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.util.crypto.SHA1;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.nio.charset.Charset;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -45,15 +48,16 @@ public class OPPOApiClient extends AbstractApiClient {
|
|
|
// 构建请求参数
|
|
|
Map<String, Object> requestBody = buildConversionParams(conversionData);
|
|
|
Long timestamp = (Long) conversionData.get("timestamp");
|
|
|
- String ownerId = (String) conversionData.get("ownerId");
|
|
|
+ String ownerId = (String) conversionData.get("adAccountId");
|
|
|
String appId = (String) conversionData.get("appId");
|
|
|
- String appKey = (String) conversionData.get("appKey");
|
|
|
- String sign = SHA1.gen(appId + appKey + timestamp);
|
|
|
- String token = Base64.encode(ownerId + "," + appId + "," + timestamp + "," + sign);
|
|
|
+ String appKey = (String) conversionData.get("appSecret");
|
|
|
+ String sign = Hashing.sha1().hashString(appId + appKey + timestamp, Charset.defaultCharset()).toString();
|
|
|
+ String token = BaseEncoding.base64().encode((ownerId + "," + appId + "," + timestamp + "," + sign).getBytes());
|
|
|
+ log.info("OPPO API请求参数:{}", requestBody);
|
|
|
// 发送HTTP请求
|
|
|
return HttpRequest.post(CONVERSION_API_URL)
|
|
|
.header("Content-Type", "application/json")
|
|
|
- .header("Authorization", "Bearer " + token)
|
|
|
+ .header("Authorization", "Bearer " + token)
|
|
|
.body(JSONUtil.toJsonStr(requestBody))
|
|
|
.timeout(SystemConstant.API_TIMEOUT)
|
|
|
.execute();
|
|
|
@@ -70,18 +74,17 @@ public class OPPOApiClient extends AbstractApiClient {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
// 落地页Id:投放广告到投放
|
|
|
- params.put("pageId", conversionData.get("traceId"));
|
|
|
+ params.put("pageId", conversionData.get("pageId"));
|
|
|
// 广告主id:对应广告主自提供
|
|
|
- params.put("adAccountId", conversionData.get("adAccountId"));
|
|
|
+ params.put("ownerId", conversionData.get("adAccountId"));
|
|
|
// 用户IP:广告主收集
|
|
|
- // params.put("ip", conversionData.get("ip"));
|
|
|
- params.put("ip", "192.168.1.1");
|
|
|
+ params.put("ip", conversionData.get("ip"));
|
|
|
// traceId:播放时追加在url上
|
|
|
- params.put("tid", conversionData.get("tid"));
|
|
|
+ params.put("tid", conversionData.get("traceId"));
|
|
|
// 流量号:播放时追加在URL上
|
|
|
params.put("lbid ", conversionData.get("lbid"));
|
|
|
// 事件
|
|
|
- params.put("transformType ", conversionData.get("eventType"));
|
|
|
+ params.put("transformType", conversionData.get("eventType"));
|
|
|
return params;
|
|
|
}
|
|
|
|