Package com.google.api.client.http

Examples of com.google.api.client.http.HttpRequest


  public <T extends IDoubanObject> T getResponse(String url, List<NameValuePair> params, Class<T> responseType, boolean needAccessToken) throws DoubanException, IOException {
    if (params != null && params.size() > 0) {
      String encodedParams = encodeParameters(params);
      url = url + "?" + encodedParams;
    }
    HttpRequest method = requestFactory.buildGetRequest(new GenericUrl(url));
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here


  public <T extends IDoubanObject> T getResponseInJson(String url, List<NameValuePair> params, Class<T> responseType, boolean needAccessToken) throws DoubanException, IOException {
    if (params != null && params.size() > 0) {
      String encodedParams = encodeParameters(params);
      url = url + "?" + encodedParams;
    }
    HttpRequest method = requestFactory.buildGetRequest(new GenericUrl(url));
    method.setParser(new JsonObjectParser(new JacksonFactory()));
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here

  public <T> T getResponseInJsonArray(String url, List<NameValuePair> params, Class<T> responseType, boolean needAccessToken) throws DoubanException, IOException {
    if (params != null && params.size() > 0) {
      String encodedParams = encodeParameters(params);
      url = url + "?" + encodedParams;
    }
    HttpRequest method = requestFactory.buildGetRequest(new GenericUrl(url));
    method.setParser(new JsonObjectParser(new JacksonFactory()));
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here

    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
 
  public String postEncodedEntry (String url, Map<String, String> params, boolean needAccessToken) throws DoubanException, IOException {
    UrlEncodedContent content = new UrlEncodedContent(params);
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAsString();
  }
View Full Code Here

  }
 
  public String postMultipartEntry (String url, Map<String, String> params, boolean needAccessToken) throws DoubanException, IOException {
    UrlEncodedContent uec = new UrlEncodedContent(params);
    MultipartRelatedContent content = new MultipartRelatedContent(uec);
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAsString();
  }
View Full Code Here

    return httpRequest(method, needAccessToken).parseAsString();
  }

  public <T, W extends IDoubanObject> W postResponse(String url, T requestObj, Class<W> responseType, boolean needAccessToken) throws DoubanException, IOException {
    AtomContent content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, requestObj);
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here

    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
 
  public <T, W extends IDoubanObject> W postResponseInJson(String url, T requestObj, Class<W> responseType, boolean needAccessToken) throws DoubanException, IOException {
    AtomContent content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, requestObj);
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    method.setParser(new JsonObjectParser(new JacksonFactory()));
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here

      content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, requestObj);
    } else {
      //Obviously the null content (proved) is not accecptable to Douban's API. Therefore, this empty obj is added for fooling Douban around, they don't care what's inside it anyway.
      content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, new DoubanUserObj());
    }
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    HttpResponse response = httpRequest(method, needAccessToken);
    return response.getStatusCode();
  }
View Full Code Here

    return response.getStatusCode();
  }

  public <T, W extends IDoubanObject> W putResponse(String url, T requestObj, Class<W> responseType, boolean needAccessToken) throws DoubanException, IOException {
    AtomContent content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, requestObj);
    HttpRequest method = requestFactory.buildPutRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here

    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
 
  public <T, W extends IDoubanObject> W putResponseInJson(String url, T requestObj, Class<W> responseType, boolean needAccessToken) throws DoubanException, IOException {
    AtomContent content = AtomContent.forEntry(DefaultConfigs.DOUBAN_XML_NAMESPACE, requestObj);
    HttpRequest method = requestFactory.buildPutRequest(new GenericUrl(url), content);
    method.setParser(new JsonObjectParser(new JacksonFactory()));
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
View Full Code Here

TOP

Related Classes of com.google.api.client.http.HttpRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.