I need my Java Twitter application to be able to follow a user in twitter. When I pass it the user ID as a string, the application follow it automatically. I couldn't find the method that can do that in Twitter4j.
Asked
Active
Viewed 4,668 times
3 Answers
17
No need for id. It will work with username as well.
mTwitter.createFriendship("dj")

Stephan
- 41,764
- 65
- 238
- 329
0
The following configuration will do it:
ConfigurationBuilder cb =new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("******")
.setOAuthConsumerSecret("******")
.setOAuthAccessToken("*******")
.setOAuthAccessTokenSecret("********");
//In case of proxy
//cb.setHttpProxyHost("******").setHttpProxyPort(8080);
TwitterFactory twitterFactory=new TwitterFactory(cb.build());
Twitter twitter=twitterFactory.getInstance();
twitter.createFriendship("twitter id");

Imran Ahmad
- 206
- 1
- 13