Browse Source

快手-获取可选的贴纸类型

yumeng 4 years ago
parent
commit
d7bb1840a5

+ 24 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -2325,4 +2325,28 @@ public class BatchController {
     }
 
 
+    @GetMapping(value = "/getCreativeWordStyles")
+    public Result<JSONArray> getCreativeWordStyles(Long accountId) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            JSONArray data = batchService.getCreativeWordStyles(accountId, oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(null);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
 }

+ 10 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
 import java.math.BigDecimal;
@@ -148,4 +149,13 @@ public interface IBatchService {
      * @return
      */
     JSONObject getWhiteList(Long accountId, String accessToken);
+
+    /**
+     * 获取可选的贴纸样式
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONArray getCreativeWordStyles(Long accountId, String accessToken);
 }

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -1780,6 +1780,36 @@ public class BatchServiceImpl implements IBatchService {
     }
 
 
+    /**
+     * 获取可选的贴纸样式
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    @Override
+    public JSONArray getCreativeWordStyles(Long accountId, String accessToken) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", accessToken);
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("advertiser_id", accountId);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        log.info("获取贴纸样式,accountId:{},data:{}", accountId, resultJson);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                return resultJson.getJSONArray("data");
+            }
+
+        }
+        return null;
+    }
+
+
 }