I first made use of the ConfigurationBuilder, which looked quite obvious to me to apply new configuration values.
ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(“***”); ... cb.setRestBaseURL("http://identi.ca/api/"); Twitter twitter = new TwitterFactory(cb.build()).getInstance();
These values are used by the twitter instance as expected, but when creating the RequestToken still the default twitter URL was created, as the configuration of the ConfigurationBuilder wasn’t propagated.
RequestToken requestToken = twitter.getOAuthRequestToken(CALLBACKURL); String authorizationUrl = requestToken.getAuthorizationURL();
After searching a while I found out that the default TwitterFactory gets all its configuration data from the system properties. Therefore I just set these values in the source code:
System.setProperty("twitter4j.oauth.consumerKey","*****"); ... System.setProperty("twitter4j.oauth.authenticationURL","https://identi.ca/api/oauth/authenticate"); System.setProperty("twitter4j.restBaseURL","http://identi.ca/api/");
A listing of the twitter4j properties can be found here Available Configuration Properties
Now the authorizationUrl can be created the “normal”, default way:
twitter = new TwitterFactory().getInstance(); RequestToken requestToken = twitter.getOAuthRequestToken(CALLBACKURL); String authorizationUrl = requestToken.getAuthorizationURL();
Hint: Don’t ever mix up the methods getAuthorizationURL and getAuthenticationURL, that cost me hours of searching!
For fast switching between the network configurations I added a network selection when logging in. I think this is a convenient way especially for testing purposes as the twitter network offers the best testing data and I can quickly make sure that it works on the status.net networks as well.
Now I’m just struggling a bit with the custom status.net network, twitter.com and identi.ca are working fine. As soon as I will have fixed this and pimped the UI a bit I eventually publish a first screen cast.ANDROID, Projektpraktikum, StatusNet, StatusNetAndroid, Twitter, twitter4j