|
@@ -1720,6 +1720,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ System.err.println(resultJson);
|
|
|
if (Check.isNull(resultJson)) {
|
|
|
log.error("获取广告创意返回结果为空,advertiserId:{}", token.getAccountId());
|
|
|
return;
|
|
@@ -1788,9 +1789,94 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void getCreative(String token, Long advertiserId, Long creativeId) {
|
|
|
+ try {
|
|
|
+ log.info("快手创意数据获取,accountId:{}", advertiserId);
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ headers.put("Access-Token", token);
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("advertiser_id", advertiserId);
|
|
|
+ param.put("creative_id", creativeId);
|
|
|
+ param.put("page_size", 200);
|
|
|
+ param.put("page", 1);
|
|
|
+
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ System.err.println(resultJson);
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
+ log.error("获取广告创意返回结果为空,advertiserId:{}", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", advertiserId, message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
+// log.error("获取广告创意返回结果数据为空,advertiserId:{}", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<KuaiShouCreative> creatives = new ArrayList<>();
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
|
+ if (!Check.isNull(detailJson)) {
|
|
|
+ KuaiShouCreative creative = new KuaiShouCreative();
|
|
|
+ creative.setId("" + advertiserId + detailJson.getLong("creative_id"));
|
|
|
+ creative.setAccountId(advertiserId);
|
|
|
+ creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
|
+ creative.setUnitId(detailJson.getLong("unit_id"));
|
|
|
+ creative.setCreativeId(detailJson.getLong("creative_id"));
|
|
|
+ creative.setCreativeName(detailJson.getString("creative_name"));
|
|
|
+ creative.setCreativeMaterialType(detailJson.getInteger("creative_material_type"));
|
|
|
+ creative.setPhotoId(detailJson.getString("photo_id"));
|
|
|
+ if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
|
|
|
+ creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
|
|
|
+ creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
|
|
|
+ }
|
|
|
+ creative.setStatus(detailJson.getInteger("status"));
|
|
|
+ creative.setPutStatus(detailJson.getInteger("put_status"));
|
|
|
+ creative.setCreateChannel(detailJson.getInteger("create_channel"));
|
|
|
+ creative.setReviewDetail(detailJson.getString("review_detail"));
|
|
|
+ creative.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
+ creative.setImageToken(detailJson.getString("image_token"));
|
|
|
+ creative.setCoverWidth(detailJson.getString("cover_width"));
|
|
|
+ creative.setCoverHeight(detailJson.getString("cover_height"));
|
|
|
+ creative.setOverlayBgUrl(detailJson.getString("overlay_bg_url"));
|
|
|
+ creative.setOverlayBgImageToken(detailJson.getString("overlay_bg_image_token"));
|
|
|
+ creative.setStickerTitle(detailJson.getString("sticker_title"));
|
|
|
+ creative.setOverlayType(detailJson.getString("overlay_type"));
|
|
|
+ creative.setClickTrackUrl(detailJson.getString("click_track_url"));
|
|
|
+ creative.setImpressionUrl(detailJson.getString("impression_url"));
|
|
|
+ creative.setAdPhotoPlayedT3sUrl(detailJson.getString("ad_photo_played_t3s_url"));
|
|
|
+ JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
|
|
|
+ if (!Check.isNull(displayInfoJson)) {
|
|
|
+ creative.setDescription(displayInfoJson.getString("description"));
|
|
|
+ creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
|
|
|
+ }
|
|
|
+ creative.setCreateTime(new Date());
|
|
|
+ creative.setUpdateTime(new Date());
|
|
|
+ creatives.add(creative);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ creativeService.replaceBatch(creatives);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public void getCreativeListByPage(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
|
try {
|
|
|
+ System.err.println("获取创意accountId:" + advertiserId);
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", " application/json");
|