|
|
@@ -455,7 +455,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
* @return map key: album_id, value: 对应的字节小程序推广链接,sslocal开头
|
|
|
*/
|
|
|
private Map<String, String> getBytedancePlayletPromoteLink(String advertiserId, String accessToken, String instanceId, List<JSONObject> requests, Set<String> errorBlanket){
|
|
|
- JSONArray playletDetailInfo = getPlayletDetail(advertiserId, accessToken, instanceId, errorBlanket);
|
|
|
+ JSONArray playletDetailInfo = getPlayletDetail(advertiserId, accessToken, instanceId, errorBlanket,1);
|
|
|
if (playletDetailInfo == null || playletDetailInfo.isEmpty()){
|
|
|
return null;
|
|
|
}
|
|
|
@@ -524,7 +524,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
continue;
|
|
|
}else {
|
|
|
String instanceid = jsonObject.getJSONObject("data").getString("instance_id");
|
|
|
- JSONArray newPlayletDetailInfo = getPlayletDetail(advertiserId, accessToken, instanceid, errorBlanket);
|
|
|
+ JSONArray newPlayletDetailInfo = getPlayletDetail(advertiserId, accessToken, instanceid, errorBlanket,1);
|
|
|
if (newPlayletDetailInfo == null || newPlayletDetailInfo.isEmpty()){
|
|
|
continue;
|
|
|
}
|
|
|
@@ -542,7 +542,19 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
|
|
|
}
|
|
|
|
|
|
- private JSONArray getPlayletDetail(String advertiserId, String accessToken, String instanceId, Set<String> errorBlanket) {
|
|
|
+ /**
|
|
|
+ * 获取字节小程序中的推广链接
|
|
|
+ * @param advertiserId
|
|
|
+ * @param accessToken
|
|
|
+ * @param instanceId
|
|
|
+ * @param errorBlanket
|
|
|
+ * @param pageNum 从外部调用填1
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private JSONArray getPlayletDetail(String advertiserId, String accessToken, String instanceId, Set<String> errorBlanket, Integer pageNum) {
|
|
|
+ if (pageNum >50){
|
|
|
+ return new JSONArray();
|
|
|
+ }
|
|
|
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);
|
|
|
@@ -550,7 +562,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("advertiser_id", advertiserId);
|
|
|
- params.put("page", "1");
|
|
|
+ params.put("page", String.valueOf(pageNum));
|
|
|
params.put("page_size", "100");
|
|
|
params.put("filtering", "{\"instance_id\":" + instanceId + "}");
|
|
|
String res = HttpUtils.httpGet(getPlayletDetailUrl, params, headers);
|
|
|
@@ -565,7 +577,15 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
System.out.println("获取字节小程序推广链接失败,code: " + code + ", msg: " + jsonObject.getString("message"));
|
|
|
return null;
|
|
|
}else {
|
|
|
- return jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
+ JSONArray list = jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
+ JSONObject page_info = jsonObject.getJSONObject("data").getJSONObject("page_info");
|
|
|
+ int total_page = page_info.getIntValue("total_page");
|
|
|
+ if (total_page > pageNum){
|
|
|
+ //递归获取下一页
|
|
|
+ JSONArray nextPage = getPlayletDetail(advertiserId, accessToken, instanceId, errorBlanket, pageNum + 1);
|
|
|
+ list.addAll(nextPage);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|
|
|
|