|
|
@@ -53,10 +53,14 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
|
|
|
@Override
|
|
|
public void test() throws Exception {
|
|
|
- String token = "009970b1323314355756a4158f363be29676d5f0";
|
|
|
- long videoId = 61073;
|
|
|
- String albumId = uploadAlbum(videoId, token);
|
|
|
- System.out.println(albumId);
|
|
|
+// uploadAlbum(1077L, 1742489802322972L, "ee6a92328075a92d6819107e0a98ef047cb210f9");
|
|
|
+// uploadAlbum();
|
|
|
+// Thread.sleep(1000);
|
|
|
+// refreshAlbumStatus();
|
|
|
+ List<String> errors = new ArrayList<>();
|
|
|
+ iapProductUpdate(errors);
|
|
|
+ System.out.println(errors);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void initNew(List<JSONObject> platformList) {
|
|
|
@@ -104,6 +108,10 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 付费短剧更新
|
|
|
+ * @param errorBlanket
|
|
|
+ */
|
|
|
private void iapProductUpdate(List<String> errorBlanket){
|
|
|
//IAP
|
|
|
List<JSONObject> iapPlatformList = bytedanceProductUpdateMapper.getIAPPlatformList();
|
|
|
@@ -138,68 +146,93 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
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"));
|
|
|
+ int rescode = uploadIapProduct(platform, obj, advertiserToLinkMap, errorBlanket, iapProductTypeMap.get(theme));
|
|
|
+ if (rescode!= 0){
|
|
|
+// return;
|
|
|
}
|
|
|
- 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("\n\n\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 付费短剧更新
|
|
|
+ * @param platform 商品库信息
|
|
|
+ * @param album 剧信息
|
|
|
+ * @param advertiserToLinkMap
|
|
|
+ * @param errorBlanket
|
|
|
+ * @param productType 商品短剧类型
|
|
|
+ */
|
|
|
+ private int uploadIapProduct(JSONObject platform, JSONObject album,
|
|
|
+ Map<String, Map<String, String>> advertiserToLinkMap,
|
|
|
+ List<String> errorBlanket,
|
|
|
+ JSONObject productType){
|
|
|
+ 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");
|
|
|
|
|
|
-// System.out.println("请求地址:" + url);
|
|
|
-// System.out.println("请求头:" + headers);
|
|
|
-// System.out.println("请求参数:" + request.toJSONString());
|
|
|
- String res = HttpUtils.httpPostRequest(url, request, headers);
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ String album_id = album.getString("album_id");
|
|
|
+ request.put("product_id", album.getLongValue("album_id"));
|
|
|
+ JSONObject product_info = new JSONObject();
|
|
|
+ product_info.put("name", album.getString("name"));
|
|
|
+ product_info.put("image_url", album.getString("img"));
|
|
|
+ product_info.put("status", 1);
|
|
|
+ product_info.put("stock", 1);
|
|
|
+ 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", album.getString("copyright_owner"));
|
|
|
+ profession.put("playlet_gender", "3");
|
|
|
+ profession.put("playlet_num", album.getString("playlet_num"));
|
|
|
+ profession.put("playlet_duration", album.getString("playlet_duration"));
|
|
|
+ profession.put("start_pay_playlet", album.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));
|
|
|
+ String play_platform = album.getString("play_platform");
|
|
|
+ if (play_platform.contains("1")){
|
|
|
+ profession.put("ad_carrier", "字节小程序");
|
|
|
+ }else {
|
|
|
+ profession.put("ad_carrier", "字节小程序");
|
|
|
+ }
|
|
|
+
|
|
|
+ //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");
|
|
|
- }
|
|
|
+ JSONObject btRes = JSONObject.parseObject(res);
|
|
|
+ int code = btRes.getIntValue("code");
|
|
|
+ if (code != 0){
|
|
|
+ errorBlanket.add("上传付费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + album.getString("name"));
|
|
|
}
|
|
|
+ return code;
|
|
|
}
|
|
|
|
|
|
private void iaaProductUpdate(List<String> errorBlanket){
|
|
|
@@ -239,48 +272,9 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
|
|
|
|
|
|
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"));
|
|
|
+ int code = uploadIaaProduct(platform, obj, advertiserToLinkMap, errorBlanket, iaaProductTypeMap.get(theme));
|
|
|
+ if (code !=0){
|
|
|
+ return;
|
|
|
}
|
|
|
// System.out.println(res);
|
|
|
// System.out.println("\n\n\n");
|
|
|
@@ -288,6 +282,61 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private int uploadIaaProduct(JSONObject platform, JSONObject album, Map<String,
|
|
|
+ Map<String, String>> advertiserToLinkMap,
|
|
|
+ List<String> errorBlanket,
|
|
|
+ JSONObject productType){
|
|
|
+ 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 = album.getString("album_id");
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("product_id", album.getLongValue("album_id"));
|
|
|
+ JSONObject product_info = new JSONObject();
|
|
|
+ product_info.put("name", album.getString("name"));
|
|
|
+ product_info.put("image_url", album.getString("img"));
|
|
|
+ product_info.put("status", 1);
|
|
|
+ product_info.put("stock", 1);
|
|
|
+ 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", album.getString("copyright_owner"));
|
|
|
+ profession.put("playlet_gender", "3");
|
|
|
+ profession.put("playlet_num", album.getString("playlet_num"));
|
|
|
+ profession.put("playlet_duration", album.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", album.getString("starting_unlock_episode"));
|
|
|
+ profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
|
|
|
+ String play_platform = album.getString("play_platform");
|
|
|
+ if (play_platform.contains("1")){
|
|
|
+ profession.put("ad_carrier", "字节小程序,微信小程序");
|
|
|
+ }else {
|
|
|
+ profession.put("ad_carrier", "字节小程序");
|
|
|
+ }
|
|
|
+ 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")+", 关联剧目: " + album.getString("name"));
|
|
|
+ }
|
|
|
+ return code;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param advertiserId 商品库主账户ID,也是创建字节小程序的ID
|
|
|
@@ -413,27 +462,98 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void uploadAlbum(){
|
|
|
+ List<Long> videoIds = bytedanceProductUpdateMapper.getUploadList();
|
|
|
+ JSONObject developerAccount = bytedanceProductUpdateMapper.getDeveloperAccount();
|
|
|
+ Long appId = developerAccount.getLong("app_id");
|
|
|
+ String appAccessToken = getAppAccessToken(appId, developerAccount.getString("app_secret"));
|
|
|
+ if (appAccessToken == null){
|
|
|
+ System.out.println("获取app_access_token失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Long videoId : videoIds){
|
|
|
+ String albumId = uploadAlbum(videoId, appId, appAccessToken);
|
|
|
+ if (albumId == null){
|
|
|
+ System.out.println("上传短剧失败,videoId: " + videoId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ bytedanceProductUpdateMapper.insertAlbumInfo(albumId, videoId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshAlbumStatus(){
|
|
|
+ JSONObject developerAccount = bytedanceProductUpdateMapper.getDeveloperAccount();
|
|
|
+ Long app_id = developerAccount.getLong("app_id");
|
|
|
+ String app_secret = developerAccount.getString("app_secret");
|
|
|
+ String appAccessToken = getAppAccessToken(app_id, app_secret);
|
|
|
+ if (appAccessToken == null){
|
|
|
+ System.out.println("获取app_access_token失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> albums = bytedanceProductUpdateMapper.selectWaitingAlbums();
|
|
|
+ for (String al : albums){
|
|
|
+ String url = "https://api.oceanengine.com/open_api/v3.0/dpa/album_status/get/";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("App-Access-Token", appAccessToken);
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("album_id", al);
|
|
|
+ params.put("app_id", app_id);
|
|
|
+ String res = HttpUtils.httpGet(url, params, headers);
|
|
|
+ if (res == null || res.isEmpty()){
|
|
|
+ System.out.println("获取短剧状态失败,albumId: " + al);
|
|
|
+ }else {
|
|
|
+ JSONObject resObj = JSONObject.parseObject(res);
|
|
|
+ int code = resObj.getIntValue("code");
|
|
|
+ if (code != 0){
|
|
|
+ System.out.println("获取短剧状态失败,code: " + code + ", msg: " + resObj.getString("message"));
|
|
|
+ continue;
|
|
|
+ }else {
|
|
|
+ JSONObject data = resObj.getJSONObject("data");
|
|
|
+ boolean isSuccess = data.getBooleanValue("can_promotion");
|
|
|
+ if (isSuccess) {
|
|
|
+ //更新状态
|
|
|
+ bytedanceProductUpdateMapper.updateAlbumInfo(al, 1, null);
|
|
|
+ }else {
|
|
|
+ String failReason = data.getString("can_not_promotion_reason");
|
|
|
+ if ("RESOURCE_CREATING".equals(failReason) || "RESOURCE_AUDITING".equals(failReason)){
|
|
|
+ //等待中
|
|
|
+ bytedanceProductUpdateMapper.updateAlbumInfo(al, 0, failReason);
|
|
|
+ }else {
|
|
|
+ //失败
|
|
|
+ bytedanceProductUpdateMapper.updateAlbumInfo(al, 2, failReason);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 上传短剧
|
|
|
* @param videoId from ly_videos
|
|
|
* @return albumId
|
|
|
*/
|
|
|
- private String uploadAlbum(long videoId, String appAccessToken){
|
|
|
+ private String uploadAlbum(long videoId, Long appId, String appAccessToken){
|
|
|
JSONObject video = bytedanceProductUpdateMapper.getVideoInfo(videoId);
|
|
|
if (video == null){
|
|
|
+ System.out.println("没有找到视频信息,videoId: " + videoId);
|
|
|
return null;
|
|
|
}
|
|
|
String videoName = video.getString("name");
|
|
|
Integer sylloge = video.getInteger("sylloge");//总集数
|
|
|
List<JSONObject> videoDetail = bytedanceProductUpdateMapper.getVideoDetail(videoId);
|
|
|
if (videoDetail == null || videoDetail.isEmpty()){
|
|
|
+ System.out.println("没有找到视频剧集详情,videoId: " + videoId);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
JSONObject requestBody = new JSONObject();
|
|
|
requestBody.put("album_title", videoName);
|
|
|
requestBody.put("seq_num", sylloge);
|
|
|
- requestBody.put("app_id", 1742489802322972L);
|
|
|
+ requestBody.put("app_id", appId);
|
|
|
|
|
|
List<JSONObject> videoDetailList = new ArrayList<>();
|
|
|
for (JSONObject obj : videoDetail){
|
|
|
@@ -457,6 +577,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
System.out.println(requestBody.toJSONString());
|
|
|
// return null;
|
|
|
String res = HttpUtils.httpPostRequest(url, requestBody, headers);
|
|
|
+ System.out.println(">>> "+res);
|
|
|
if (res == null || res.isEmpty()){
|
|
|
System.out.println("上传短剧失败, 返回null");
|
|
|
return null;
|
|
|
@@ -474,4 +595,30 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private String getAppAccessToken(Long app_id, String app_secret){
|
|
|
+ String url = "https://open.oceanengine.com/open_api/oauth2/app_access_token/";
|
|
|
+ if (app_id == null || app_secret == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject body = new JSONObject();
|
|
|
+ body.put("app_id", app_id);
|
|
|
+ body.put("secret", app_secret);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ String res = HttpUtils.httpPostRequest(url, body, headers);
|
|
|
+ if (res == null || res.isEmpty()){
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ JSONObject resObj = JSONObject.parseObject(res);
|
|
|
+ int code = resObj.getIntValue("code");
|
|
|
+ if (code != 0){
|
|
|
+ System.out.println("获取app_access_token失败,code: " + code + ", msg: " + resObj.getString("message"));
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ return resObj.getJSONObject("data").getString("access_token");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|