use of com.bc.pmpheep.wechat.po.WXjsTicket in project pmph by BCSquad.
the class WechatAccessToken method getWXjsTicket.
/**
* <pre>
* 功能描述:获取wx_js_ticket
* 使用示范:
*
* @param accessToken access_token
* @return
* </pre>
*/
public static WXjsTicket getWXjsTicket(String accessToken) {
WXjsTicket wXjsTicket = null;
String requestUrl = WXURLUtil.JSAPIURL.replace("ACCESS_TOKEN", accessToken);
// 发起GET请求获取凭证
JSONObject jsonObject = HttpRequestUtil.httpRequest(requestUrl, "GET", null);
System.out.println("CommonUtil.java 调用了一次getWXjsTicket接口");
if (null != jsonObject) {
try {
wXjsTicket = new WXjsTicket();
wXjsTicket.setJsTicket(jsonObject.getString("ticket"));
wXjsTicket.setJsTicketExpiresIn(jsonObject.getInt("expires_in"));
} catch (JSONException e) {
wXjsTicket = null;
// 获取wXjsTicket失败
log.error("获取wXjsTicket失败 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
}
}
return wXjsTicket;
}
Aggregations