Reputation: 560
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.
Upvotes: 11
Views: 4680
Reputation: 216
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");
Upvotes: 0
Reputation:
No need for id. It will work with username as well.
mTwitter.createFriendship("dj")
Upvotes: 17
Reputation: 560
Problem solved ,you can follow a user using twitter.createFriendship("twitter id");
method
Upvotes: 7