|
|
@@ -0,0 +1,407 @@
|
|
|
+package cn.com.ctop.job.bytedance.data.service.impl;
|
|
|
+
|
|
|
+import cn.com.ctop.job.bytedance.data.mapper.BytedanceProductUpdateMapper;
|
|
|
+import cn.com.ctop.job.bytedance.data.service.IBytedanceProductUpdateService;
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
|
+import cn.com.ctop.job.bytedance.utils.FeishuRobotUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdateService {
|
|
|
+ @Resource
|
|
|
+ BytedanceProductUpdateMapper bytedanceProductUpdateMapper;
|
|
|
+
|
|
|
+ public static final String APP_ID = "ttba3acc87250c6f7901";
|
|
|
+ public static final String HOOK_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/92e2445e-76df-44fb-8f61-f55ac94f49bd";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() throws Exception {
|
|
|
+ List<String> errors = new ArrayList<>();
|
|
|
+ log.info("付费商品库更新中...");
|
|
|
+ iapProductUpdate(errors);
|
|
|
+ log.info("付费商品库更新完成");
|
|
|
+ log.info("免费商品库更新中...");
|
|
|
+ iaaProductUpdate(errors);
|
|
|
+ log.info("免费商品库更新完成");
|
|
|
+ if (!Check.isNull(errors)){
|
|
|
+// List<String> users = Arrays.asList(
|
|
|
+// "44fbaed6" //zhaotx
|
|
|
+// ,"58e7a98a" //xsq
|
|
|
+// );
|
|
|
+ FeishuRobotUtil.sendTextToWebhook(StringUtils.join(errors, "\n"), HOOK_URL);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initNew(){
|
|
|
+ List<JSONObject> iapPlatformList = bytedanceProductUpdateMapper.getIAPPlatformList();
|
|
|
+ List<JSONObject> iaaPlatformList = bytedanceProductUpdateMapper.getIAAPlatformList();
|
|
|
+ initNew(iaaPlatformList);
|
|
|
+ initNew(iapPlatformList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initNew(List<JSONObject> platformList) {
|
|
|
+ //为广告主账户创建新的字节小程序
|
|
|
+ //step1 查询表里广告主是否都有自己的字节小程序、
|
|
|
+ //step2 如果没有,创建新的字节小程序
|
|
|
+ for (JSONObject obj : platformList){
|
|
|
+ if (obj.containsKey("mini_instance_id") && !Check.isNull(obj.get("mini_instance_id"))){
|
|
|
+ //已经有字节小程序了
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String createLinkUrl = "https://api.oceanengine.com/open_api/v3.0/tools/micro_app/create/";
|
|
|
+ String advertiser_id = obj.getString("advertiser_id");
|
|
|
+ String access_token = obj.getString("access_token");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", access_token);
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
+ requestBody.put("advertiser_id", Long.parseLong(advertiser_id));
|
|
|
+ requestBody.put("app_id", obj.getString("mi_appid"));
|
|
|
+ requestBody.put("remark", "商品库管理用");
|
|
|
+ requestBody.put("tag_info", "1050107001");
|
|
|
+ JSONObject app_page = new JSONObject();
|
|
|
+ app_page.put("link", "");
|
|
|
+ app_page.put("link_remark", "init");
|
|
|
+ app_page.put("start_page", "pages/index/index");
|
|
|
+ app_page.put("start_param", "link_id=574391");
|
|
|
+ requestBody.put("app_page", app_page);
|
|
|
+
|
|
|
+ String res = HttpUtils.httpPostRequest(createLinkUrl, requestBody, headers);
|
|
|
+ if (res == null || res.isEmpty()){
|
|
|
+ System.out.println("创建字节小程序失败");
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ int code = jsonObject.getIntValue("code");
|
|
|
+ if (code != 0) {
|
|
|
+ System.out.println("创建字节小程序失败,code: " + code + ", msg: " + jsonObject.getString("message"));
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ String instanceId = jsonObject.getJSONObject("data").getString("instance_id");
|
|
|
+ //更新表
|
|
|
+ bytedanceProductUpdateMapper.updateInstanceId(advertiser_id, instanceId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void iapProductUpdate(List<String> errorBlanket){
|
|
|
+ //IAP
|
|
|
+ List<JSONObject> iapPlatformList = bytedanceProductUpdateMapper.getIAPPlatformList();
|
|
|
+ List<JSONObject> iapVideoList = bytedanceProductUpdateMapper.getIAPVideoList();
|
|
|
+ List<JSONObject> iapProductTypeEnums = bytedanceProductUpdateMapper.getIAPProductTypeEnums();
|
|
|
+ Map<String, Map<String, String>> advertiserToLinkMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (JSONObject obj : iapPlatformList){
|
|
|
+ String advertiserId = obj.getString("advertiser_id");
|
|
|
+ String accessToken = obj.getString("access_token");
|
|
|
+ String instanceId = obj.getString("mini_instance_id");
|
|
|
+ if (instanceId == null){
|
|
|
+ errorBlanket.add("没有找到字节小程序的实例ID: " + advertiserId);
|
|
|
+ System.out.println("没有找到字节小程序的实例ID: " + advertiserId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, String> albumIdToLinkMap = getBytedancePlayletPromoteLink(advertiserId, accessToken, instanceId, iapVideoList, errorBlanket);
|
|
|
+ advertiserToLinkMap.put(advertiserId, albumIdToLinkMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, JSONObject> iapProductTypeMap = iapProductTypeEnums.stream().collect(Collectors.toMap(
|
|
|
+ obj -> obj.getString("third_type_name"),
|
|
|
+ obj -> obj,
|
|
|
+ (existing, replacement) -> replacement
|
|
|
+ ));
|
|
|
+ for (JSONObject obj : iapVideoList){
|
|
|
+ String theme = obj.getString("theme");
|
|
|
+ if (!iapProductTypeMap.containsKey(theme)){
|
|
|
+ errorBlanket.add("上传商品:没有找到对应的产品类型:" + theme);
|
|
|
+ System.out.println(">>>>没有找到对应的产品类型:" + theme);
|
|
|
+ System.out.println("\n\n\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (JSONObject platform : iapPlatformList) {
|
|
|
+ String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", platform.getString("access_token"));
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ String album_id = obj.getString("album_id");
|
|
|
+ request.put("product_id", obj.getLongValue("album_id"));
|
|
|
+ JSONObject product_info = new JSONObject();
|
|
|
+ product_info.put("name", obj.getString("name"));
|
|
|
+ product_info.put("image_url", obj.getString("img"));
|
|
|
+ product_info.put("status", 1);
|
|
|
+ product_info.put("stock", 1);
|
|
|
+ JSONObject productType = iapProductTypeMap.get(theme);
|
|
|
+ product_info.put("first_category_id", productType.getString("first_type_id"));
|
|
|
+ product_info.put("sub_category_id", productType.getString("second_type_id"));
|
|
|
+ product_info.put("third_category_id", productType.getString("third_type_id"));
|
|
|
+ product_info.put("first_category", productType.getString("first_type_name"));
|
|
|
+ product_info.put("sub_category", productType.getString("second_type_name"));
|
|
|
+ product_info.put("third_category", productType.getString("third_type_name"));
|
|
|
+ request.put("advertiser_id", platform.getLongValue("advertiser_id"));
|
|
|
+ request.put("platform_id", platform.getLongValue("platform_id"));
|
|
|
+ JSONObject profession = new JSONObject();
|
|
|
+ profession.put("copyright_owner", obj.getString("copyright_owner"));
|
|
|
+ profession.put("playlet_gender", "3");
|
|
|
+ profession.put("playlet_num", obj.getString("playlet_num"));
|
|
|
+ profession.put("playlet_duration", obj.getString("playlet_duration"));
|
|
|
+ profession.put("start_pay_playlet", obj.getString("start_pay_playlet"));
|
|
|
+ if (platform.getDouble("max_charge") > 0.0){
|
|
|
+ profession.put("max_charge", platform.getString("max_charge"));
|
|
|
+ }
|
|
|
+ if (platform.getDouble("min_charge") > 0.0){
|
|
|
+ profession.put("min_charge", platform.getString("min_charge"));
|
|
|
+ }
|
|
|
+ if (platform.getDouble("recommended_charge") > 0.0){
|
|
|
+ profession.put("recommended_charge", platform.getString("recommended_charge"));
|
|
|
+ }
|
|
|
+ profession.put("has_paid_content", "1");
|
|
|
+ profession.put("has_motivation_content", "2");
|
|
|
+ profession.put("membership_types", platform.getString("membership_types"));
|
|
|
+ profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
|
|
|
+ //price_info
|
|
|
+ JSONObject price_info = new JSONObject();
|
|
|
+ price_info.put("price", platform.getDoubleValue("single_price"));
|
|
|
+ product_info.put("price_info", price_info);
|
|
|
+ product_info.put("profession", profession);
|
|
|
+ request.put("product_info", product_info);
|
|
|
+
|
|
|
+
|
|
|
+// System.out.println("请求地址:" + url);
|
|
|
+// System.out.println("请求头:" + headers);
|
|
|
+// System.out.println("请求参数:" + request.toJSONString());
|
|
|
+ String res = HttpUtils.httpPostRequest(url, request, headers);
|
|
|
+// System.out.println(res);
|
|
|
+ JSONObject btRes = JSONObject.parseObject(res);
|
|
|
+ int code = btRes.getIntValue("code");
|
|
|
+ if (code != 0){
|
|
|
+ errorBlanket.add("上传付费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + obj.getString("name"));
|
|
|
+ }
|
|
|
+// System.out.println("\n\n\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void iaaProductUpdate(List<String> errorBlanket){
|
|
|
+ //IAA
|
|
|
+ List<JSONObject> iaaPlatformList = bytedanceProductUpdateMapper.getIAAPlatformList();
|
|
|
+ List<JSONObject> iaaVideoList = bytedanceProductUpdateMapper.getIAAVideoList();
|
|
|
+ List<JSONObject> iaaProductTypeEnums = bytedanceProductUpdateMapper.getIAAProductTypeEnums();
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> advertiserToLinkMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (JSONObject obj : iaaPlatformList){
|
|
|
+ String advertiserId = obj.getString("advertiser_id");
|
|
|
+ String accessToken = obj.getString("access_token");
|
|
|
+ String instanceId = obj.getString("mini_instance_id");
|
|
|
+ if (instanceId == null){
|
|
|
+ errorBlanket.add("没有找到字节小程序的实例ID: " + advertiserId);
|
|
|
+ System.out.println("没有找到字节小程序的实例ID: " + advertiserId);
|
|
|
+ continue; //todo
|
|
|
+ }
|
|
|
+ Map<String, String> albumIdToLinkMap = getBytedancePlayletPromoteLink(advertiserId, accessToken, instanceId, iaaVideoList, errorBlanket);
|
|
|
+ advertiserToLinkMap.put(advertiserId, albumIdToLinkMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, JSONObject> iaaProductTypeMap = iaaProductTypeEnums.stream().collect(Collectors.toMap(
|
|
|
+ obj -> obj.getString("third_type_name"),
|
|
|
+ obj -> obj,
|
|
|
+ (existing, replacement) -> replacement
|
|
|
+ ));
|
|
|
+ for (JSONObject obj : iaaVideoList){
|
|
|
+ String theme = obj.getString("theme");
|
|
|
+ if (!iaaProductTypeMap.containsKey(theme)){
|
|
|
+ errorBlanket.add("上传商品:没有找到对应的产品类型:" + theme);
|
|
|
+ System.out.println(">>>>没有找到对应的产品类型:" + theme);
|
|
|
+ System.out.println("\n\n\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (JSONObject platform : iaaPlatformList) {
|
|
|
+ String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", platform.getString("access_token"));
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ String album_id = obj.getString("album_id");
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("product_id", obj.getLongValue("album_id"));
|
|
|
+ JSONObject product_info = new JSONObject();
|
|
|
+ product_info.put("name", obj.getString("name"));
|
|
|
+ product_info.put("image_url", obj.getString("img"));
|
|
|
+ product_info.put("status", 1);
|
|
|
+ product_info.put("stock", 1);
|
|
|
+ JSONObject productType = iaaProductTypeMap.get(theme);
|
|
|
+ product_info.put("first_category_id", productType.getString("first_type_id"));
|
|
|
+ product_info.put("sub_category_id", productType.getString("second_type_id"));
|
|
|
+ product_info.put("third_category_id", productType.getString("third_type_id"));
|
|
|
+ product_info.put("first_category", productType.getString("first_type_name"));
|
|
|
+ product_info.put("sub_category", productType.getString("second_type_name"));
|
|
|
+ product_info.put("third_category", productType.getString("third_type_name"));
|
|
|
+ JSONObject profession = new JSONObject();
|
|
|
+ profession.put("copyright_owner", obj.getString("copyright_owner"));
|
|
|
+ profession.put("playlet_gender", "3");
|
|
|
+ profession.put("playlet_num", obj.getString("playlet_num"));
|
|
|
+ profession.put("playlet_duration", obj.getString("playlet_duration"));
|
|
|
+ profession.put("has_paid_content", "2");
|
|
|
+ profession.put("has_motivation_content", "2");
|
|
|
+ profession.put("membership_types", "5");
|
|
|
+ profession.put("starting_unlock_episode", obj.getString("starting_unlock_episode"));
|
|
|
+ profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
|
|
|
+ product_info.put("profession", profession);
|
|
|
+ request.put("product_info", product_info);
|
|
|
+ request.put("advertiser_id", platform.getLongValue("advertiser_id"));
|
|
|
+ request.put("platform_id", platform.getLongValue("platform_id"));
|
|
|
+
|
|
|
+// System.out.println("请求地址:" + url);
|
|
|
+// System.out.println("请求头:" + headers);
|
|
|
+// System.out.println("请求参数:" + request.toJSONString());
|
|
|
+ String res = HttpUtils.httpPostRequest(url, request, headers);
|
|
|
+ JSONObject btRes = JSONObject.parseObject(res);
|
|
|
+ int code = btRes.getIntValue("code");
|
|
|
+ if (code != 0){
|
|
|
+ errorBlanket.add("上传免费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + obj.getString("name"));
|
|
|
+ }
|
|
|
+// System.out.println(res);
|
|
|
+// System.out.println("\n\n\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param advertiserId 商品库主账户ID,也是创建字节小程序的ID
|
|
|
+ * @param accessToken 广告账号的access_token
|
|
|
+ * @param instanceId 字节小程序的实例ID
|
|
|
+ * @return map key: album_id, value: 对应的字节小程序推广链接,sslocal开头
|
|
|
+ */
|
|
|
+ private Map<String, String> getBytedancePlayletPromoteLink(String advertiserId, String accessToken, String instanceId, List<JSONObject> requests, List<String> errorBlanket){
|
|
|
+ JSONArray playletDetailInfo = getPlayletDetail(advertiserId, accessToken, instanceId, errorBlanket);
|
|
|
+ if (playletDetailInfo == null || playletDetailInfo.isEmpty()){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<String> reqAlbumIds = requests.stream()
|
|
|
+ .map(obj -> obj.getString("album_id"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Map<String, String> res = new HashMap<>(reqAlbumIds.size());
|
|
|
+
|
|
|
+ for (int i = 0; i < playletDetailInfo.size(); i++) {
|
|
|
+ JSONObject obj = playletDetailInfo.getJSONObject(i);
|
|
|
+ String startParam = obj.getString("start_param");
|
|
|
+ for (String album_id : reqAlbumIds){
|
|
|
+ if (startParam.contains("tt_album_id="+album_id)){
|
|
|
+ res.put(album_id, obj.getString("link"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<JSONObject> unfound = requests.stream()
|
|
|
+ .filter(obj -> !res.containsKey(obj.getString("album_id")))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (unfound.isEmpty()){
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ //没有找到对应的album_id,需要新建链接
|
|
|
+ for (JSONObject obj : unfound){
|
|
|
+ String editLinkUrl = "https://api.oceanengine.com/open_api/v3.0/tools/micro_app/update/";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
+ requestBody.put("advertiser_id", Long.parseLong(advertiserId));
|
|
|
+ requestBody.put("instance_id", Long.parseLong(instanceId));
|
|
|
+ JSONObject app_page = new JSONObject();
|
|
|
+ String name = obj.getString("name");
|
|
|
+ app_page.put("link", "");
|
|
|
+ app_page.put("remark", "生成商品用-"+name);
|
|
|
+ app_page.put("link_remark", "生成商品用-"+name);
|
|
|
+ app_page.put("operate_type", "NEW");
|
|
|
+ app_page.put("start_page", "pages/index/index");
|
|
|
+ String video_id = obj.getString("video_id");
|
|
|
+ String album_id = obj.getString("album_id");
|
|
|
+ String video_detail_id = obj.getString("video_detail_id");
|
|
|
+ String platform_config = obj.getString("platform_config");
|
|
|
+ JSONObject pconfig = JSONObject.parseObject(platform_config);
|
|
|
+ String tt_episode_id = pconfig.getJSONObject("douyinyun").getString("episode_id");
|
|
|
+ String start_param = "tt_album_id=" + album_id + "&video_id=" + video_id + "&video_detail_id=" + video_detail_id + "&tt_episode_id=" + tt_episode_id + "&source=link&type=1";
|
|
|
+ app_page.put("start_param", start_param);
|
|
|
+ JSONArray app_page_list = new JSONArray();
|
|
|
+ app_page_list.add(app_page);
|
|
|
+ requestBody.put("app_page", app_page_list);
|
|
|
+ requestBody.put("tag_info", "1050107001");
|
|
|
+// System.out.println("\n\n请求地址:" + editLinkUrl);
|
|
|
+// System.out.println("请求头:" + headers);
|
|
|
+// System.out.println("请求参数:" + requestBody.toJSONString());
|
|
|
+
|
|
|
+ String rr = HttpUtils.httpPostRequest(editLinkUrl, requestBody, headers);
|
|
|
+ if (rr == null || rr.isEmpty()){
|
|
|
+ errorBlanket.add("创建字节小程序推广链接失败, 广告账号ID:" + advertiserId + ", 小程序资产ID:" + instanceId);
|
|
|
+ System.out.println("创建字节小程序推广链接失败");
|
|
|
+ return res;
|
|
|
+ }else {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(rr);
|
|
|
+ int code = jsonObject.getIntValue("code");
|
|
|
+ if (code != 0) {
|
|
|
+ errorBlanket.add("创建字节小程序推广链接失败,code: " + code + ", msg: " + jsonObject.getString("message") + ", 广告账号ID:" + advertiserId + ", 小程序资产ID:" + instanceId);
|
|
|
+ System.out.println("创建字节小程序推广链接失败,code: " + code + ", msg: " + jsonObject.getString("message"));
|
|
|
+ continue;
|
|
|
+ }else {
|
|
|
+ String instanceid = jsonObject.getJSONObject("data").getString("instance_id");
|
|
|
+ JSONArray newPlayletDetailInfo = getPlayletDetail(advertiserId, accessToken, instanceid, errorBlanket);
|
|
|
+ if (newPlayletDetailInfo == null || newPlayletDetailInfo.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < newPlayletDetailInfo.size(); i++) {
|
|
|
+ JSONObject link = newPlayletDetailInfo.getJSONObject(i);
|
|
|
+ String startParam = link.getString("start_param");
|
|
|
+ if (startParam.contains("tt_album_id="+album_id)){
|
|
|
+ res.put(album_id, link.getString("link"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONArray getPlayletDetail(String advertiserId, String accessToken, String instanceId, List<String> errorBlanket) {
|
|
|
+ String getPlayletDetailUrl = "https://api.oceanengine.com/open_api/v3.0/tools/asset_link/list/";
|
|
|
+ getPlayletDetailUrl = getPlayletDetailUrl.replace("${ADVERTISER_ID}", advertiserId);
|
|
|
+ getPlayletDetailUrl = getPlayletDetailUrl.replace("${INSTANCE_ID}", instanceId);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("advertiser_id", advertiserId);
|
|
|
+ params.put("page", "1");
|
|
|
+ params.put("page_size", "100");
|
|
|
+ params.put("filtering", "{\"instance_id\":" + instanceId + "}");
|
|
|
+ String res = HttpUtils.httpGet(getPlayletDetailUrl, params, headers);
|
|
|
+ if (res == null || res.isEmpty()) {
|
|
|
+ errorBlanket.add("获取字节小程序推广链接失败, 广告账号ID:" + advertiserId + ", 小程序资产ID:" + instanceId);
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ int code = jsonObject.getIntValue("code");
|
|
|
+ if (code != 0) {
|
|
|
+ errorBlanket.add("获取字节小程序推广链接失败,code: " + code + ", msg: " + jsonObject.getString("message") + ", 广告账号ID:" + advertiserId + ", 小程序资产ID:" + instanceId);
|
|
|
+ System.out.println("获取字节小程序推广链接失败,code: " + code + ", msg: " + jsonObject.getString("message"));
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ return jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|