/**
   * 获得用户认证的地址
   *
   * @param redirectURL
   * @return
   */
  public String getOAuthURL(String redirectURL) throws UnsupportedEncodingException {
    Map<String, Object> parameters = new HashMap<>();

    parameters.put("appid", this.appid);
    parameters.put("redirect_uri", URLEncoder.encode(redirectURL, "utf-8"));
    parameters.put("response_type", "code");
    parameters.put("scope", "snsapi_userinfo");
    parameters.put("state", StringUtils.randomString(8));

    return _USER_AUTH_URL_
        + "?"
        + StringUtils.generateQueryString(parameters, false)
        + "#wechat_redirect";
  }
  /**
   * 获得授权用户基本信息
   *
   * @param accessToken
   * @param openId
   * @return
   */
  public UserInfo getUserInfo(String accessToken, String openId) {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("access_token", accessToken);
    parameters.put("openid", openId);
    parameters.put("lang", "zh_CN");

    String url = _USER_INFO_URL_ + "?" + StringUtils.generateQueryString(parameters, false);
    String result = WebUtils.get(url);

    UserInfo userInfo = null;
    if (result != null) {
      Gson gson = new Gson();
      userInfo = gson.fromJson(result, UserInfo.class);
    }

    return userInfo;
  }
  /**
   * 获取用户授权后的访问票据
   *
   * @param code
   * @return
   */
  public AccessToken getAccessToken(String code) {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("appid", this.appid);
    parameters.put("secret", this.appSecret);
    parameters.put("code", code);
    parameters.put("grant_type", "authorization_code");

    String url = _ACCESS_URL_ + "?" + StringUtils.generateQueryString(parameters, false);
    String result = WebUtils.get(url);

    AccessToken accessToken = null;
    if (result != null) {
      Gson gson = new Gson();
      accessToken = gson.fromJson(result, AccessToken.class);
    }

    return accessToken;
  }