Skip to content

Instantly share code, notes, and snippets.

@twaddington
Created September 27, 2012 18:33
Show Gist options
  • Save twaddington/3795600 to your computer and use it in GitHub Desktop.
Save twaddington/3795600 to your computer and use it in GitHub Desktop.
// We imply that we expect a JSON response by using the SFJsonRequestHandler...
Future f = client.getPath("/foo/bar", new SFJsonRequesthandler() {
@Override
public void onStart() {
// Pass
}
@Override
public void onFinish() {
// Pass
}
@Override
public void onSuccess(SFJsonResponse response) {
// Get the plaintext response
String content = response.getContent();
// Get the parsed JSON response
JSONObject json = response.getJSONObject();
}
@Override
public void onComplete(SFJsonResponse response) {
// Request completed, but returned a non-success response code.
int code = response.getResponseCode();
}
@Override
public void onFailure(Throwable e) {
// The request failed to complete due to a timeout, a
// networking exception or some other error condition.
}
});
if (f.isDone()) {
// Get the result
Object o = f.get();
} else {
// Cancel the request
f.cancel();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment