RCK69 RCK69 - 29 days ago 6
Android Question

jtwitter library: connecting to alternative service fails


EDIT

omg I clearly should take a break... logcat gives these errors and as
it seems the catch-block is also executed but the messages are
actually sent as I have verified by visiting the page:
http://yamba.marakana.com/

Actually a thing that took me 2 hours to get aware of.. can someone
please tell me why the app still wants to connect to twitter too?


I am following this tutorial from MarakanaTechTV: https://www.youtube.com/watch?v=-P1eiRy-klk&feature=relmfu

It's about building a twitter-like client but for simplicity (avoiding OAuth) its useing its own service located here: http://yamba.marakana.com/ username is student and password is password.

here is my code:

public void onClick(View v) {
final String statusText = editStatus.getText().toString();

//zeitkritische Aufgaben wie z.b. networking oder DB Zugriff dürfen nicht im main-thread laufen
//App crashed sonst
new Thread() {
public void run() {
try {
Twitter twitter = new Twitter("student", "password");
twitter.setAPIRootUrl("http://yamba.marakana.com/api");
twitter.setStatus(statusText);
} catch (Exception e) {
Log.e("error", "DIED", e);
//e.printStackTrace(e);

}
}
}.start();

Log.d("StatusActivity", "onClicked! with text: " + statusText);
}
}


and here is what logcat gives me:


04-08 20:48:14.329: D/gralloc_goldfish(1935): Emulator without GPU emulation detected.
04-08 20:48:17.019: D/StatusActivity(1935): onClicked! with text: ggfdg
04-08 20:48:23.308: D/StatusActivity(1935): onClicked! with text: ggfdg
04-08 20:48:24.438: E/error(1935): DIED
04-08 20:48:24.438: E/error(1935): winterwell.jtwitter.TwitterException$E401: Unauthorized http://twitter.com/account/rate_limit_status.json (student)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.URLConnectionHttpClient.processError(URLConnectionHttpClient.java:125)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.URLConnectionHttpClient.getPage(URLConnectionHttpClient.java:91)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.URLConnectionHttpClient.processError(URLConnectionHttpClient.java:143)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.URLConnectionHttpClient.post(URLConnectionHttpClient.java:219)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.Twitter.post(Twitter.java:1944)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:2555)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:2502)
04-08 20:48:24.438: E/error(1935): at winterwell.jtwitter.Twitter.setStatus(Twitter.java:2274)
04-08 20:48:24.438: E/error(1935): at com.example.yamba.StatusActivity$1.run(StatusActivity.java:34)


It seems that the app tries to connect to twitter despite the fact that it should connect to the marakana-service because of this line:

twitter.setAPIRootUrl("http://yamba.marakana.com/api");

Answer Source

I also faced the same issue. My mistake was I forgot to remove the code for Toast from the catch block