Android extension example


I am looking for an example on how to implement the extension functionality described at

I would like to get a list of users friends using the “/1.1/friends/ids.json”

How to get all followers/friends with the cursor parameter in Android

Using the example listed, we can modify it to work with the “/1.1/friends/ids.json” link like so:

import retrofit.http.GET;
import retrofit.http.Query;

public class MyTwitterApiClient extends TwitterApiClient {
    public MyTwitterApiClient(Session session) {

     * Provide FriendsService with ids
    public FriendsService getFriendsService() {
        return getService(FriendsService.class);

    public interface FriendsService {
        void ids(@Query("user_id") Long userId,
                 @Query("screen_name") String screenName,
                 @Query("cursor") Long cursor,
                 @Query("stringify_ids") Boolean stringifyIds,
                 @Query("count") Integer count,
                 Callback<Ids> cb);

        void idsByUserId(@Query("user_id") Long userId, 
                         Callback<Ids> cb);

    public class Ids {
        public final Long previousCursor;

        public final Long[] ids;

        public final Long nextCursor;

        public Ids(Long previousCursor, Long[] ids, Long nextCursor) {
            this.previousCursor = previousCursor;
            this.ids = ids;
            this.nextCursor = nextCursor;

This can then be used like so:

MyTwitterApiClient client = new MyTwitterApiClient(Twitter.getSessionManager().getActiveSession());
        client.getFriendsService().idsByUserId(id, new Callback<MyTwitterApiClient.Ids>() {
            public void success(Result<MyTwitterApiClient.Ids> result) {

            public void failure(TwitterException exception) {


Thank you very much! This is extremely helpful!

closed #4