Get a user's first tweet

android
oauth

#1

Hi,

I am trying to get a user’s first tweet, the latest one, but i am not able to do so.
Steps:

  1. I created an app in my own account and also authorized the app to generate the access token and access secret.
  2. I used the owner_id as the tweet id and used TweetUI kit to load the kit but then it doesnot return a failure callback and not even a success callback
  3. To solve #2 i added dependencies of ok-http to the latest versions but then it still does not return a callback.

I switched over to the get api and guest authentication, but i get a 403 error forbidden, and that i need to connect with the support to increase the api call limits

Since that option too did not work, i tried implementing the app-only authentication
I followed all the steps as per the twitter forums but then i get a code 99 error, even when everything is as per the document. I tried the same using postman (Chrome plugin) but all in vain.

What i want to achieve is this:

  1. Get the latest tweet from a public page. So i was trying this with my id first if it works before asking for client credentials.

Please assist.
I have almost spent 3 days but not achieving anything.

Do let me know if code is required.

Thanks


#2

You can get a list of a user’s tweets by using the StatusesService’s userTimeline method.

Example:

TwitterSession session= Twitter.getSessionManager().getActiveSession();

Twitter.getApiClient(session).getStatusesService().userTimeline(null, "user_name", null, null, null, false, false, true, true, new Callback<List<Tweet>>() {
    @Override
    public void success(Result<List<Tweet>> listResult) {

       // do something with the result, list of tweets is in listResult.data

    }

    @Override
    public void failure(TwitterException e) {

    }
} );

If you want to get the latest tweet, you can look for the biggest “createdAt” or “id” value in the list.

I hope this helps :slight_smile:


#3