当前位置: 首页>>代码示例>>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;未经允许,请勿转载。