Exemplo n.º 1
0
 /**
  * 取授权页URL
  *
  * @param responseType
  * @return
  * @throws XueqiuException
  */
 public String getAuthorizeUrl(String responseType) throws XueqiuException {
   return Config.getValue("authorize_url").trim()
       + "?client_id="
       + Config.getValue("client_id").trim()
       + "&response_type="
       + responseType
       + "&redirect_uri="
       + Config.getValue("redirect_uri").trim();
 }
Exemplo n.º 2
0
  /**
   * 获取access_token
   *
   * @param refreshToken
   * @return
   * @throws XueqiuException
   */
  public AccessToken getAccessTokenByRefreshToken(String refreshToken) throws XueqiuException {

    Map<String, String> params = new HashMap<String, String>();
    params.put("client_id", Config.getValue("client_id"));
    params.put("client_secret", Config.getValue("client_secret"));
    params.put("grant_type", "refresh_token");
    params.put("refresh_token", refreshToken);

    String json = HttpClientUtil.sendPost(Config.getValue("access_token_url"), params);

    return getAccessTokenFromJson(json);
  }
Exemplo n.º 3
0
  /**
   * 获取access_token
   *
   * @param code
   * @return
   * @throws XueqiuException
   */
  public AccessToken getAccessTokenByCode(String code) throws XueqiuException {

    Map<String, String> params = new HashMap<String, String>();
    params.put("client_id", Config.getValue("client_id"));
    params.put("client_secret", Config.getValue("client_secret"));
    params.put("grant_type", "authorization_code");
    params.put("code", code);

    String json = HttpClientUtil.sendPost(Config.getValue("access_token_url"), params);

    return getAccessTokenFromJson(json);
  }