File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -54,26 +54,21 @@ How to Build a Basic Twitter Rest Client
54
54
}
55
55
}
56
56
57
+
57
58
// Use the TwitterRestClient in your app
58
59
import org.json.*;
59
60
import com.loopj.android.http.*;
60
61
61
62
class TwitterRestClientUsage {
62
- public void getPublicTimeline() {
63
+ public void getPublicTimeline() throws JSONException {
63
64
TwitterRestClient.get("statuses/public_timeline.json", null, new JsonHttpResponseHandler() {
64
65
@Override
65
- public void onSuccess(Object response) {
66
- JSONArray timeline = (JSONArray)response;
67
-
68
- try {
69
- JSONObject firstEvent = timeline.get(0);
70
- String tweetText = firstEvent.getString("text");
66
+ public void onSuccess(JSONArray response) {
67
+ JSONObject firstEvent = timeline.get(0);
68
+ String tweetText = firstEvent.getString("text");
71
69
72
- // Do something with the response
73
- System.out.println(tweetText);
74
- } catch(JSONException e) {
75
- e.printStackTrace();
76
- }
70
+ // Do something with the response
71
+ System.out.println(tweetText);
77
72
}
78
73
});
79
74
}
You can’t perform that action at this time.
0 commit comments