Browse Source

快手 创建接口 请求头新增字段:K-RealUser-IP

zhaoxian 2 years ago
parent
commit
355d3dd37e

+ 4 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java

@@ -16,6 +16,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -25,6 +26,8 @@ import java.util.Map;
 @Service
 public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
 
+    @Value("${kuaishou.realuser-ip}")
+    private String realUserIP;
 
     @Autowired
     private IKuaiShouGroupService getKuaiShouGroupService;
@@ -440,6 +443,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
             String accessToken = requestJson.getString("access_token");
             Map<String, String> headers = new HashMap<>();
             headers.put("Access-Token", accessToken);
+            headers.put("K-RealUser-IP", realUserIP);
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);

+ 8 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -90,6 +90,7 @@ import org.apache.http.ParseException;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.RedisUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -194,6 +195,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private RedisUtil redisUtil;
     private static ExecutorService cutExecutorService = Executors.newFixedThreadPool(10);
 
+    @Value("${kuaishou.realuser-ip}")
+    private String realUserIP;
+
     @Override
     public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
         try {
@@ -924,7 +928,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         try {
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_CREATE;
             Map<String, String> headers = new HashMap<>();
+
             headers.put("Access-Token", accessToken);
+            headers.put("K-RealUser-IP", realUserIP);
             headers.put("Content-Type", " application/json");
             requestJson.put("advertiser_id", advertiserId);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
@@ -984,6 +990,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             Map<String, String> headers = new HashMap<>();
             requestJson.put("advertiser_id", advertiserId);
             headers.put("Access-Token", accessToken);
+            headers.put("K-RealUser-IP", realUserIP);
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
@@ -2174,6 +2181,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             requestJson.put("advertiser_id", advertiserId);
             Map<String, String> header = new HashMap<String, String>();
             header.put("Content-Type", " application/json");
+            header.put("K-RealUser-IP", realUserIP);
             header.put("Access-Token", accessToken);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), header);
             JSONObject resultJson = JSONObject.parseObject(result);

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/v3/service/impl/V3KuaishouAccountDetailsServiceImpl.java

@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -20,6 +21,8 @@ import java.util.Map;
 @Slf4j
 @Service
 public class V3KuaishouAccountDetailsServiceImpl implements V3KuaishouAccountDetailsService {
+    @Value("${kuaishou.realuser-ip}")
+    private String realUserIP;
 
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
@@ -36,6 +39,7 @@ public class V3KuaishouAccountDetailsServiceImpl implements V3KuaishouAccountDet
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.V3_CREATE_CASCADE_ALL;
             Map<String, String> headers = new HashMap<>();
             headers.put("Access-Token", accessToken);
+            headers.put("K-RealUser-IP", realUserIP);
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             resultJson = JSONObject.parseObject(result);
@@ -74,6 +78,7 @@ public class V3KuaishouAccountDetailsServiceImpl implements V3KuaishouAccountDet
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.V3_CREATE_UNIT_AND_CREATIVE;
             Map<String, String> headers = new HashMap<>();
             headers.put("Access-Token", accessToken);
+            headers.put("K-RealUser-IP", realUserIP);
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
              resultJson = JSONObject.parseObject(result);

+ 3 - 0
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-dev.yml

@@ -283,3 +283,6 @@ duxiaoman:
   url: https://dev-liang.duxiaoman.com
   appId: 1660011893128
   token: 99e6dfa5ff790437200521fd13d6128c
+
+kuaishou:
+  realuser-ip: 103.46.170.107

+ 4 - 0
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-prod.yml

@@ -272,3 +272,7 @@ duxiaoman:
   url: https://liang.duxiaoman.com
   appId: 1660012052762
   token: 1f8a5a1cbd4d626a2aa197b86f6cab8a
+
+kuaishou:
+  realuser-ip: 103.46.170.107
+

+ 4 - 1
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-test.yml

@@ -287,4 +287,7 @@ rule:
 duxiaoman:
   url: https://dev-liang.duxiaoman.com
   appId: 1660011893128
-  token: 99e6dfa5ff790437200521fd13d6128c
+  token: 99e6dfa5ff790437200521fd13d6128c
+
+kuaishou:
+  realuser-ip: 103.46.170.107