| | |
| | | package com.yeshi.buwan.pptv; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.pptv.entity.PPTVProgram; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.NameValuePair; |
| | | import org.apache.commons.httpclient.methods.PostMethod; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.yeshi.utils.HttpUtil; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | public class PPTVApiUtil { |
| | | static Logger logger = LoggerFactory.getLogger(PPTVApiUtil.class); |
| | | |
| | | private final static String APP_KEY = "eb324ec4439e193c38fd8d7fdbdae9af"; |
| | | private final static String APP_SECRET = "163cf4fa3780091e61a48c6abb6246d3"; |
| | | private final static String CHANNEL_ID = "111111"; |
| | | //正式 |
| | | public final static String APP_KEY = "9227024a6c540a7f8571d75c469da9ba"; |
| | | private final static String APP_SECRET = "f3e922ac18f9da6c816d3012f8b7e575"; |
| | | |
| | | //测试 |
| | | // private final static String APP_KEY = "eb324ec4439e193c38fd8d7fdbdae9af"; |
| | | // private final static String APP_SECRET = "163cf4fa3780091e61a48c6abb6246d3"; |
| | | |
| | | |
| | | public final static String CHANNEL_ID = "253350"; |
| | | private final static String CANAL = "buwan"; |
| | | |
| | | private static String getBase64(String str) { |
| | | String st = StringUtil.getBase64(str).replace("\r\n", ""); |
| | |
| | | } |
| | | |
| | | private static List<PPTVSeries> getList(String method) { |
| | | String result = baseRequest(null, method); |
| | | String result = baseRequest(new HashMap<>(), method); |
| | | logger.error(result); |
| | | List<String> list = parseUrls(result); |
| | | List<PPTVSeries> totalList = new ArrayList<>(); |
| | |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("uid", uid); |
| | | String result = baseRequest("https://coapi.pptv.com/coapi-web/api/http/sopRequest", params, "pptv.channel.openid.get"); |
| | | logger.info(result); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | return resultJSON.optJSONObject("response").optJSONObject("body").optString("openId"); |
| | | } |
| | |
| | | */ |
| | | public static void login(String code) { |
| | | String url = String.format("https://coapi.pptv.com/coapi-web/api/getUserToken/%s/%s.htm", APP_KEY, code); |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("code", code); |
| | | String result = baseRequest(url, params, ""); |
| | | logger.info(result); |
| | | String result = HttpUtil.get(url); |
| | | |
| | | System.out.println(result); |
| | | // JSONObject resultJSON = JSONObject.fromObject(result); |
| | | // return resultJSON.optJSONObject("response").optJSONObject("body").optString("openId"); |
| | | } |