Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Access Twitter’s REST API

Eric Frohnhoefer edited this page Dec 7, 2017 · 1 revision

TwitterCore provides a TwitterApiClient for making authenticated Twitter API requests. It currently has support for the following:

  • Statuses (Tweets)
    • mentionsTimeline
    • userTimeline
    • homeTimeline
    • retweetsOfMe
    • show
    • lookup
    • update
    • retweet
    • unretweet
    • destroy
  • Favorites
    • list
    • create
    • destroy
  • Search
    • tweets
  • Lists
    • statuses
  • Collections
    • entries

Your app must have acquired a Session in order to use the TwitterApiClient. A TwitterSession can be acquired by having a user login with Twitter. To make requests without requiring a user to login, guest authentication can be used. Note, guest authentication may only be used to make API requests that do not require a user context. For example, you cannot Tweet with a GuestSession.

Once you are authenticated you can start using the TwitterApiClient to make API Requests.

Tweets

Extensions

TwitterApiClient is fully extensible and can be extended to add additional Twitter authenticated endpoints. In addition, TwitterApiClient can be constructed with user defined HTTP client, which enables developers to set HTTP interceptors, custom timeouts, and other optional params defined in OkHttpClient.

Extending TwitterApiClient

Extending TwitterApiClient to add additional Twitter authenticated endpoints.

Twitter Kit uses Retrofit to convert interfaces into authenticated representations of our endpoints. Any additional endpoints added through the extensible example need to adhere to the format required by Retrofit.

Log Requests and Responses

To demonstrate an example of creating a custom HTTP client, we will setup OkHttp's HttpLoggingInterceptor for logging requests and responses.

Note

HttpLoggingInterceptor is not provided in Twitter Kit.