I am using Fabric sdk for Twitter. In this I am able to make login request as it\'s described in its document. Now I wan\'t to get list of follower of logged in user and show in
The second method (using TwitterApiClient
) is almost correct except for the response data model. Refere https://dev.twitter.com/rest/reference/get/followers/list for the structure of the response. You need to build a data model according to this structure.
Here is the fix :
//data model
public class Followers {
@SerializedName("users")
public final List users;
public Followers(List users) {
this.users = users;
}
}
class MyTwitterApiClient extends TwitterApiClient {
public MyTwitterApiClient(TwitterSession session) {
super(session);
}
public CustomService getCustomService() {
return getService(CustomService.class);
}
}
interface CustomService {@GET("/1.1/followers/list.json")
void show(@Query("user_id") Long userId, @Query("screen_name") String
var, @Query("skip_status") Boolean var1, @Query("include_user_entities") Boolean var2, @Query("count") Integer var3, Callback < Followers > cb);
}
new MyTwitterApiClient(session).getCustomService().show(userID, null, true, true, 100, new Callback < Followers > () {@Override
public void success(Result < Followers > result) {
Log.i("Get success", "" + result.data.users.size());
}
@Override
public void failure(TwitterException e) {
}
});
The above code is working for me. Hope it helps!