Я делаю приложение для Android, чтобы общаться с термостатом NEST, используя недавно выпущенный API. Я следую инструкциям, приведенным на этой странице: https://developer.nest.com/documentation/how-to-auth.
У меня это работает до того момента, когда я успешно получаю access_token. Однако используя этот access_token и отправляя HTTP-запрос GET на https://developer-api.nest.com/devices.json?auth={access_token} Я получаю исключение по тайм-ауту соединения!
@mccv Вот мой код:
private void make_REST_call(String access_token) {
String access_token_uri = "https://developer-api.nest.com/devices.json?auth="+access_token;
try {
URI uri = new URI(access_token_uri);
// Set the connection timeout value to X seconds (30000 milliseconds)
final HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 100000); // In miliseconds
httpclient = new DefaultHttpClient(httpParams);
HttpGet httpget = new HttpGet();
httpget.setURI(new URI(access_token_uri));
// Execute HTTPs GET request
Long reqTime = System.currentTimeMillis();
Log.d(tag + " make_REST_call", " reqTime time= " + reqTime);
HttpResponse response = null;
try {
response = httpclient.execute(httpget);
Log.d(tag + " make_REST_call", " response is= " + response.getEntity());
}
catch (Exception e) {
e.printStackTrace();
Log.e(tag + " make_REST_call", e.toString());
}
Long resTime = System.currentTimeMillis();
Log.d(tag + " make_REST_call", " response time= " + (resTime - reqTime));
}
catch (Exception e) {
Log.e(access_token_uri, e.toString());
e.printStackTrace();
}
}