我正在使用OkHttpClient来获取Gson。我正在使用这个Yahoo API网址:
http://query.yahooapis.com/v1/public/yql?q=select+*+from+yahoo.finance.historicaldata+where+symbol+%3D+%22YHOO%22+and+startDate+%3D+%222015-11-19%22+and+endDate+%3D+%222016-11-19%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
之前有效,但有时无效。
OkHttpClient mClient = new OkHttpClient();
public String fetchStockHistory(String url) {
try {
Request request = new Request.Builder()
.url(url)
.build();
Response response = mClient.newCall(request).execute();
return response.body().string();
} catch (Exception e){
e.printStackTrace();
}
return null;
}