Fetching Followers List in Twitter


#1

My task is to fetch the followers list.I am able to fetch the user id.I know the url of followers list but somehow I am not able to fetch the user list in android.
TwitterLoginButton twitterLoginButton;
public static final String ROOT_URL = “https://api.twitter.com/”;

// Note: Your consumer key and secret should be obfuscated in your source code before shipping.


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));
    setContentView(R.layout.activity_main);
    twitterLoginButton = (TwitterLoginButton) findViewById(R.id.twitter_login_button);
    twitterLoginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {
            //If login succeeds passing the Calling the login method and passing Result object
            login(result);
        }

        @Override
        public void failure(TwitterException exception) {
            //If failure occurs while login handle it here
            Log.d("TwitterKit", "Login with Twitter failure", exception);
        }
    });

}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //Adding the login result back to the button
    twitterLoginButton.onActivityResult(requestCode, resultCode, data);
}

public void login(Result<TwitterSession> result) {
    //Creating a twitter session with result's data
    TwitterSession session = result.data;

    //Getting the username from session
    final String userName = session.getUserName();
    Log.d("Username",userName);

    //Getting the account service of the user logged in
    Call<User> call = Twitter.getApiClient(session).getAccountService()
            .verifyCredentials(true, false);
    call.enqueue(new Callback<User>() {
        @Override
        public void failure(TwitterException e) {
            //If any error occurs handle it here
        }
        @Override
        public void success(Result<User> userResult) {
            //If it succeeds creating a User object from userResult.data
            User user = userResult.data;
           // setProfilePic(user.profileImageUrl.replace("_normal", ""));
            twitterLoginButton.setVisibility(View.GONE);

        }

    });

 



   MyTwitterApiClient myTwitterApiClient=new MyTwitterApiClient(session);
    Call<Response> cal2=myTwitterApiClient.getCustomService().exampleCallback(result.data.getUserId());
    cal2.enqueue(new Callback<Response>() {
        @Override
        public void success(Result<Response> result) {

            Log.d("success","result");

        }

        @Override
        public void failure(TwitterException exception) {
          Log.d("failure","failure");
        }
    });

}
class MyTwitterApiClient extends TwitterApiClient{
public MyTwitterApiClient(TwitterSession session) {
super(session);
}

    public CustomService getCustomService() {
        return getService(CustomService.class);
    }
}

public interface CustomService
{
    @GET("/1.1/followers/list.json")
    Call<Response> exampleCallback(@Query("user_id") long id);

}