From 0a18a8cb0a7a57bf1f82df425251334c57f8c39a Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 一月 2021 15:40:37 +0800 Subject: [PATCH] 新增手机号/qq/微信绑定 --- src/main/java/com/yeshi/buwan/funtv/FunTVNewApi.java | 212 ++++++++++++++++++++++++++++------------------------ 1 files changed, 115 insertions(+), 97 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/funtv/FunTVNewApi.java b/src/main/java/com/yeshi/buwan/funtv/FunTVNewApi.java index be4d844..db8a8ff 100644 --- a/src/main/java/com/yeshi/buwan/funtv/FunTVNewApi.java +++ b/src/main/java/com/yeshi/buwan/funtv/FunTVNewApi.java @@ -5,7 +5,6 @@ import com.yeshi.buwan.funtv.entity.FunTVAlbum2; import com.yeshi.buwan.funtv.entity.FunTVShortVideo2; import com.yeshi.buwan.funtv.entity.FunTVVideo2; -import com.yeshi.buwan.funtv.vo.*; import com.yeshi.buwan.util.HttpUtil; import com.yeshi.buwan.util.StringUtil; import com.yeshi.buwan.util.TimeUtil; @@ -20,6 +19,9 @@ public class FunTVNewApi { private static final String CP = "fk84vly"; private static final String SECRET_KEY = "eD*r3dZNQ%7"; + + private static final String APP_ID = "b22whcwhkc4uczk7"; + private static final String APP_SECRET = "wrLDM2QLJWPM1Oem"; private static String accessToken; private static long accessTokenInvalidTime; @@ -81,25 +83,17 @@ * @param pageSize * @param startTime 寮�濮嬫椂闂� * @param endTime 缁撴潫鏃堕棿 - * @param channelId 棰戦亾ID 1-鐢靛奖 2-鐢佃鍓� 3-鍔ㄦ极 4-缁艰壓 5-灏戝効 * @param status 0琛ㄧず涓嶅彲鐢ㄥ獟浣擄紝1琛ㄧず鍙敤濯掍綋锛�2琛ㄧず鍏ㄩ儴濯掍綋 * @return */ - public static Funtv2ResultVO getAlbums(int page, int pageSize, Long startTime, Long endTime, Integer channelId, Integer status) { - String url = "http://papi.funshion.com/cp/syncmv"; + public static Funtv2ResultVO getAlbums(int page, int pageSize, Long startTime, Long endTime, Integer status) { + String url = "http://pfmg.funshion.com/v1/cp/syncmv"; Map<String, String> params = new HashMap<>(); params.put("mtype", "media"); - if (startTime == null) - params.put("start", "0"); - else + if (startTime != null) params.put("start", TimeUtil.getGernalTime(startTime, "yyyyMMddHHmm")); - if (endTime == null) - params.put("end", "0"); - else + if (endTime != null) params.put("end", TimeUtil.getGernalTime(endTime, "yyyyMMddHHmm")); - - if (channelId != null) - params.put("channel", channelId + ""); if (status != null) params.put("status", status + ""); @@ -109,15 +103,19 @@ try { String result = baseRequest(url, params); + + System.out.println(result); JSONObject json = JSONObject.fromObject(result); if (json.optInt("code") == 0) { - JSONArray array = json.optJSONArray("datas"); + JSONArray array = json.optJSONArray("data"); List<FunTVAlbum2> album2List = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVAlbum2>>() { }.getType()); for (FunTVAlbum2 album2 : album2List) if (album2.getEpisodes() != null) - for (FunTVVideo2 video2 : album2.getEpisodes()) + for (FunTVVideo2 video2 : album2.getEpisodes()) { video2.setMediaId(album2.getId()); + video2.setFunH5Url(String.format("http://m.fun.tv/focplay/?mid=%s&vid=%s&malliance=fk84vly", album2.getId(), video2.getId())); + } int totalCount = json.optInt("total"); return new Funtv2ResultVO(totalCount, album2List); } @@ -127,89 +125,109 @@ return null; } - public static FunTVAlbum2 getAlbumsDetail(String aid) { - String url = "http://papi.funshion.com/cp/syncmv"; +// public static FunTVAlbum2 getAlbumsDetail(String aid) { +// String url = "http://papi.funshion.com/cp/syncmv"; +// Map<String, String> params = new HashMap<>(); +// params.put("mtype", "media"); +// params.put("id", aid); +// try { +// String result = baseRequest(url, params); +// JSONObject json = JSONObject.fromObject(result); +// if (json.optInt("code") == 0) { +// JSONArray array = json.optJSONArray("datas"); +// List<FunTVAlbum2> album2List = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVAlbum2>>() { +// }.getType()); +// for (FunTVAlbum2 album2 : album2List) +// if (album2.getEpisodes() != null) +// for (FunTVVideo2 video2 : album2.getEpisodes()) +// video2.setMediaId(album2.getId()); +// if (album2List != null && album2List.size() > 0) +// return album2List.get(0); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return null; +// } + +// +// public static Funtv2ResultVO getVideos(int page, int pageSize, Long startTime, Long endTime, Integer channelId, Integer status) { +// String url = "http://papi.funshion.com/cp/syncmv"; +// Map<String, String> params = new HashMap<>(); +// params.put("mtype", "video"); +// if (startTime == null) +// params.put("start", "0"); +// else +// params.put("start", TimeUtil.getGernalTime(startTime, "yyyyMMddHHmm")); +// if (endTime == null) +// params.put("end", "0"); +// else +// params.put("end", TimeUtil.getGernalTime(endTime, "yyyyMMddHHmm")); +// +// if (channelId != null) +// params.put("channel", channelId + ""); +// +// if (status != null) +// params.put("status", status + ""); +// +// params.put("page_size", pageSize + ""); +// params.put("page_no", page + ""); +// +// try { +// String result = baseRequest(url, params); +// JSONObject json = JSONObject.fromObject(result); +// if (json.optInt("code") == 0) { +// JSONArray array = json.optJSONArray("datas"); +// List<FunTVShortVideo2> videoList = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVShortVideo2>>() { +// }.getType()); +// int totalCount = json.optInt("total"); +// return new Funtv2ResultVO(totalCount, videoList); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return null; +// } + +// +// public static FunTVShortVideo2 getVideoDetail(String vid) { +// String url = "http://papi.funshion.com/cp/syncmv"; +// Map<String, String> params = new HashMap<>(); +// params.put("mtype", "video"); +// params.put("id", vid); +// +// try { +// String result = baseRequest(url, params); +// JSONObject json = JSONObject.fromObject(result); +// if (json.optInt("code") == 0) { +// JSONArray array = json.optJSONArray("datas"); +// List<FunTVShortVideo2> videoList = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVShortVideo2>>() { +// }.getType()); +// if (videoList != null && videoList.size() > 0) +// return videoList.get(0); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return null; +// } + + /** + * 鑾峰彇鎺堟潈鐮� + * + * @return + */ + public static String getAuthCode() { + String url = "http://pfmg.funshion.com/v1/config/authcode"; Map<String, String> params = new HashMap<>(); - params.put("mtype", "media"); - params.put("id", aid); - try { - String result = baseRequest(url, params); - JSONObject json = JSONObject.fromObject(result); - if (json.optInt("code") == 0) { - JSONArray array = json.optJSONArray("datas"); - List<FunTVAlbum2> album2List = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVAlbum2>>() { - }.getType()); - for (FunTVAlbum2 album2 : album2List) - if (album2.getEpisodes() != null) - for (FunTVVideo2 video2 : album2.getEpisodes()) - video2.setMediaId(album2.getId()); - if (album2List != null && album2List.size() > 0) - return album2List.get(0); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - - public static Funtv2ResultVO getVideos(int page, int pageSize, Long startTime, Long endTime, Integer channelId, Integer status) { - String url = "http://papi.funshion.com/cp/syncmv"; - Map<String, String> params = new HashMap<>(); - params.put("mtype", "video"); - if (startTime == null) - params.put("start", "0"); - else - params.put("start", TimeUtil.getGernalTime(startTime, "yyyyMMddHHmm")); - if (endTime == null) - params.put("end", "0"); - else - params.put("end", TimeUtil.getGernalTime(endTime, "yyyyMMddHHmm")); - - if (channelId != null) - params.put("channel", channelId + ""); - - if (status != null) - params.put("status", status + ""); - - params.put("page_size", pageSize + ""); - params.put("page_no", page + ""); - - try { - String result = baseRequest(url, params); - JSONObject json = JSONObject.fromObject(result); - if (json.optInt("code") == 0) { - JSONArray array = json.optJSONArray("datas"); - List<FunTVShortVideo2> videoList = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVShortVideo2>>() { - }.getType()); - int totalCount = json.optInt("total"); - return new Funtv2ResultVO(totalCount, videoList); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - - public static FunTVShortVideo2 getVideoDetail(String vid) { - String url = "http://papi.funshion.com/cp/syncmv"; - Map<String, String> params = new HashMap<>(); - params.put("mtype", "video"); - params.put("id", vid); - - try { - String result = baseRequest(url, params); - JSONObject json = JSONObject.fromObject(result); - if (json.optInt("code") == 0) { - JSONArray array = json.optJSONArray("datas"); - List<FunTVShortVideo2> videoList = new Gson().fromJson(array.toString(), new TypeToken<List<FunTVShortVideo2>>() { - }.getType()); - if (videoList != null && videoList.size() > 0) - return videoList.get(0); - } - } catch (Exception e) { - e.printStackTrace(); + params.put("ctime", System.currentTimeMillis() + ""); + params.put("appid", APP_ID); + params.put("sign", org.yeshi.utils.StringUtil.Md5(APP_ID + "_" + params.get("ctime") + "_" + APP_SECRET)); + String result = HttpUtil.get(url, params); + System.out.println(result); + JSONObject json = JSONObject.fromObject(result); + if (json.optInt("retcode") == 200) { + return json.optJSONObject("data").optString("auth_code"); } return null; } -- Gitblit v1.8.0