當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpResponse.parseAsString方法代碼示例

本文整理匯總了Java中com.google.api.client.http.HttpResponse.parseAsString方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpResponse.parseAsString方法的具體用法?Java HttpResponse.parseAsString怎麽用?Java HttpResponse.parseAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.api.client.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.parseAsString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPublicKeysJson

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
/**
 *
 * @return
 * @throws IOException
 */
private JsonObject getPublicKeysJson() throws IOException {
    // get public keys
    URI uri = URI.create(pubKeyUrl);
    GenericUrl url = new GenericUrl(uri);
    HttpTransport http = new NetHttpTransport();
    HttpResponse response = http.createRequestFactory().buildGetRequest(url).execute();

    // store json from request
    String json = response.parseAsString();
    // disconnect
    response.disconnect();

    // parse json to object
    JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();

    return jsonObject;
}
 
開發者ID:rvep,項目名稱:dev_backend,代碼行數:23,代碼來源:FirebaseAuthVerifier.java

示例2: get

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
protected Response get(String endPoint, Date modifiedAfter, Map<String, String> params) throws IOException {
    HttpResponse resp = null;

    OAuthRequestResource req = new OAuthRequestResource(config, signerFactory, endPoint, "GET", null, params);
    req.setToken(token);
    req.setTokenSecret(tokenSecret);
    if (modifiedAfter != null) {
        req.setIfModifiedSince(modifiedAfter);
    }

    try {
        resp = req.execute();
        String r = resp.parseAsString();
        return unmarshallResponse(r, Response.class);
    } catch (IOException ioe) {
        throw xeroExceptionHandler.convertException(ioe);
    }
}
 
開發者ID:XeroAPI,項目名稱:Xero-Java,代碼行數:19,代碼來源:XeroClient.java

示例3: handleResponse

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
/**
 * Handler that will be invoked when an error response is received.
 * 
 * @param request Instance of {@link HttpRequest}
 * @param response Instance of {@link HttpResponse}
 * @param supportsRetry Flag that indicates whether there will be a retry if this handler
 * returns true. 
 */
@Override
public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry)
		throws IOException {	
	
	IOException exception;
	
	try {
		String responseString = response.parseAsString();
		
		ErrorMessage msg = jsonFactory.fromString(responseString, ErrorMessage.class);
		
		exception = new ApiException(msg);
	} catch (IOException e) {
		String errorMessage = "Couldn't parse JSON error message: " + e.getMessage();
		
		logger.severe(errorMessage);
		
		exception = new ApiException(errorMessage);
	}
	
	throw exception;
}
 
開發者ID:ambi-verse,項目名稱:nlu-api-client-java,代碼行數:31,代碼來源:UnsuccessfulResponseHandler.java

示例4: retrieveRemoteJwksUri

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
private GenericUrl retrieveRemoteJwksUri(String openIdUrl) {
  try {
    GenericUrl genericUrl = new GenericUrl(openIdUrl);
    HttpResponse httpResponse = this.httpRequestFactory.buildGetRequest(genericUrl).execute();
    String json = httpResponse.parseAsString();
    ProviderMetadata metadata = OBJECT_MAPPER.readValue(json, ProviderMetadata.class);
    return new GenericUrl(metadata.getJwksUri());
  } catch (IOException exception) {
    throw new UnauthenticatedException("Cannot retrieve or parse OpenId Provider Metadata",
        exception);
  }
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:13,代碼來源:DefaultKeyUriSupplier.java

示例5: retrieveJwksJson

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
private String retrieveJwksJson(GenericUrl jwksUri) {
  try {
    HttpResponse response = this.httpRequestFactory.buildGetRequest(jwksUri).execute();
    return response.parseAsString();
  } catch (IOException exception) {
    String message = String.format("Cannot retrive the JWKS json from %s", jwksUri.build());
    throw new UnauthenticatedException(message, exception);
  }
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:10,代碼來源:DefaultJwksSupplier.java

示例6: getCardFromResponse

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
protected static Card getCardFromResponse(HttpResponse response)
{
	String responseString = "";
	try {
		responseString = response.parseAsString();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	Card[] returnedCardArr = gson.fromJson(responseString, Card[].class);
	
	return returnedCardArr[0];		
}
 
開發者ID:TeraInferno,項目名稱:MTG-CardSort,代碼行數:15,代碼來源:ApiUtil.java

示例7: getStationsList

import com.google.api.client.http.HttpResponse; //導入方法依賴的package包/類
public List<Station> getStationsList(Location location, String nextPageToken) {

		double latitude = location.getLat();
		double longitude = location.getLng();

		this._latitude = latitude;
		this._longitude = longitude;
		String types="gas_station";

		try {

			HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
			HttpRequest request = httpRequestFactory
					.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
			request.getUrl().put("types", types);
			request.getUrl().put("rankby", "distance");
			request.getUrl().put("location", _latitude + "," + _longitude);
			request.getUrl().put("sensor", "false");
			request.getUrl().put("key", API_KEY);

			if(nextPageToken!=null && !nextPageToken.isEmpty())
				request.getUrl().put("pagetoken",nextPageToken);

			HttpResponse response = request.execute();
			String str = response.parseAsString();

			return parser.listFromJson(str);

		} catch (java.io.IOException e) {
			Log.e("Error:", e.getMessage());
			return null;
		}
	}
 
開發者ID:Gaso-UFS,項目名稱:gaso,代碼行數:34,代碼來源:GooglePlaces.java


注:本文中的com.google.api.client.http.HttpResponse.parseAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。