I am developing an application to retrieve Twitter feeds. I wrote the following
try {
codeString x = "";
Twitter y;
HttpClient pingclient = new DefaultHttpClient();
HttpPost pingpost = new HttpPost("https://twitter.com/statuses/user_timeline/krish_hari.json");
pingpost.addHeader("Accepts", "application/json");
pingpost.addHeader("Content-type", "application/json");
org.apache.http.HttpResponse pingResponse = pingclient.execute(pingpost);
HttpEntity loginEntity = pingResponse.getEntity();
String result = EntityUtils.toString(loginEntity);
//InputStream is = this.getResources().openRawResource(R.raw.jsontwitter);
//byte [] buffer = new byte[is.available()];
//while (is.read(buffer) != -1);
//String jsontext = new String(buffer);
JSONArray entries = new JSONArray(result);
x = "JSON parsed.\nThere are [" + entries.length() + "]\n\n";
int i;
for (i=0;i<entries.length();i++) {
JSONObject post = entries.getJSONObject(i);
x += "------------\n";
x += "Date:" + post.getString("created_at") + "\n";
x += "Post:" + post.getString("text") + "\n\n";
}
tvData.setText(x);
}
catch (Exception je) {
tvData.setText("Error w/file: " + je.getMessage());
}
I get the error error w/file:twitter.com. Can anyone help me to crack this?
I use this code to retrieve Twitter feed:
url[0]is the URL to the JSON feed.You must reformat your URL, this format you’re using now is deprecated.
Refer to https://dev.twitter.com/docs/api/1/get/statuses/user_timeline