use of org.scribe.model.Response in project data-transfer-project by google.
the class SmugMugInterface method getImageAsStream.
public InputStream getImageAsStream(String urlStr) {
OAuthRequest request = new OAuthRequest(Verb.GET, urlStr);
oAuthService.signRequest(accessToken, request);
final Response response = request.send();
return response.getStream();
}
use of org.scribe.model.Response in project fitscales by paulburton.
the class FitBitSyncService method syncWeight.
@Override
public boolean syncWeight(float weight) {
try {
SimpleDateFormat tsFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
String timestamp = tsFormat.format(new Date());
OAuthRequest request = new OAuthRequest(Verb.POST, API_BASE + "/user/-/body.json");
request.addBodyParameter("weight", String.format("%.2f", weight));
request.addBodyParameter("date", timestamp);
oaService.signRequest(oaToken, request);
Response response = request.send();
int code = response.getCode();
if (DEBUG) {
Log.d(TAG, "Response code " + code);
try {
Log.d(TAG, "Response body " + response.getBody());
} catch (Exception ex) {
Log.e(TAG, "Response body error", ex);
}
}
if (code == 200 || code == 201 || code == 204)
return true;
return false;
} catch (Exception ex) {
return false;
}
}
use of org.scribe.model.Response in project fitscales by paulburton.
the class RunKeeperSyncService method postOAuth.
@Override
protected void postOAuth() {
try {
OAuthRequest request = new OAuthRequest(Verb.GET, API_BASE + "/profile");
request.addHeader("Accept", "application/vnd.com.runkeeper.Profile+json");
oaService.signRequest(oaToken, request);
Response response = request.send();
String body = response.getBody();
if (DEBUG)
Log.d(TAG, "Got profile body " + body);
JSONObject json = new JSONObject(body);
user = json.getString("name");
} catch (Exception ex) {
user = "unknown";
}
}
Aggregations