예제 #1
0
  public static JSONObject getJSAPITicketFromWX(String access_token) {
    try {
      String getURL =
          "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="
              + access_token
              + "&type=jsapi";
      String retJStr = HttpGetUtils.get(getURL);
      JSONParser parser = new JSONParser();
      JSONObject jobj = (JSONObject) parser.parse(retJStr);
      Integer errcode = Integer.parseInt(String.valueOf(jobj.get("errcode")));
      if (errcode == 0) {
        return jobj;
      }

    } catch (Exception e) {
      e.toString();
    }
    return null;
  }
예제 #2
0
 public static JSONObject getAccessTokenFromWX() {
   try {
     String getURL =
         "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
             + JOYWXJSServiceImpl.appid
             + "&secret="
             + JOYWXJSServiceImpl.secret;
     logger.trace("getURL: " + getURL);
     String retJStr = HttpGetUtils.get(getURL);
     logger.trace("retJStr: " + retJStr);
     JSONParser parser = new JSONParser();
     JSONObject jobj = (JSONObject) parser.parse(retJStr);
     String access_token = String.valueOf(jobj.get("access_token"));
     String expires_in = String.valueOf(jobj.get("expires_in"));
     logger.trace("access_token: " + access_token);
     logger.trace("expires_in: " + expires_in);
     if (access_token != null && expires_in != null) return jobj;
   } catch (Exception e) {
     e.toString();
   }
   return null;
 }