I am working on a project wherein i have a requirement to follow a person using Twitter. For that purpose I am using Twitter SDK along with the OAuth ConsumerKey, ConsumerSecret, AccessToken and AccessTokenSecret. Everything works fine but I am completely stuck up with the things to follow the user based on the registered twitter account in the device.
What I tried
I have tried to follow a user based on the OAuth tokens generated for my application from the apps.twitter.com. Please find the below method that I am using to follow a person
private void doTwitterTask() {
screenName = "takeoffandroid";
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("cgxxxxxxxxxwtk")
.setOAuthConsumerSecret("9h3xxxxxxxxxxXAKG")
.setOAuthAccessToken("3890xxxxxxxxxxJLa2nED")
.setOAuthAccessTokenSecret("Q3Hxxxxxx5PK");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
twitter.createFriendship(screenName);
} catch (TwitterException e) {
Log.d("MCG","Error");
}
}
The above method works fine but the follow count is submitted from the main account where i have registered the application from apps.twitter.com not from the device registered user account. Please help me how to proceed with my requirement. Any kind of hint and tips would be helpful to me. Thanks in advance.