Android TwitterApiClient: what is correct callback syntax for the POST method?


#1

I have created a stackoverflow.com post - sorry Twitter it’s easier to discuss it there :slightly_smiling:


#2

(Moved to the REST API thread as this is not Fabric related).


#3

Difficult to respond here unless you provide us with some further information about your question?


#4

Here’s my hack. If there is a better solution please let me know or update the stackoverflow.com link.
Can the API be improved to avoid creating the List if it already exists? There should be a reasonable default and the opposite functionality can be another parameter passed in the POST call. e.g. by default the API would allow duplicates, but the API could take a duplicate=no parameter if needed.

interface CustomService {
    @POST("/1.1/lists/create.json")
    void createList(@Query("name") String name, @Query("mode") String mode, Callback<JsonElement> cb);
}

MyTwitterApiClient api = new MyTwitterApiClient(session);
api.getCustomService().createList("MyListName", "private", new Callback<JsonElement>() {
    @Override
    public void success(Result<JsonElement> result) {
       Log.d(TAG, " [success] status: " + result.response.getStatus());
       JsonElement je = result.data;
       Log.d(TAG, " [success] data: " + je.getAsJsonObject().toString());
    }
    @Override
       public void failure(TwitterException e) { }
    });