I am consuming few apis from TwitterKit. I want to fetch home timeline of user where user will see list of tweets from his follower. If we check the api documentation for home timeline, the parameters are optional. Now twitter kit provides all required things. I found the way to access the home timeline api through Twitter kit only, but problem is its returning 400 always. If you noticed even if the parameter is optional I have to pass them. Find the code below.
Actual method in the Twitter Kit
/**
* Returns a collection of the most recent Tweets and retweets posted by the authenticating user
* and the users they follow. The home timeline is central to how most users interact with the
* Twitter service.
* <p>
* The Twitter REST API goes back up to 800 tweets on the home timeline.
* It is more volatile for users that follow many users or follow users who Tweet frequently.
*
* @param count (optional) Specifies the number of tweets to try and retrieve, up to a maximum
* of 200. The value of count is best thought of as a limit to the number of tweets
* to return because suspended or deleted content is removed after the count has
* been applied. We include retweets in the count, even if include_rts is not
* supplied. It is recommended you always send include_rts=1 when using this API
* method.
* @param sinceId (optional) Returns results with an ID greater than (that is, more recent than)
* the specified ID. There are limits to the number of Tweets which can be
* accessed through the API. If the limit of Tweets has occurred since the
* since_id, the since_id will be forced to the oldest ID available.
* @param maxId (optional) Returns results with an ID less than (that is, older than) or equal
* to the specified ID.
* @param trimUser (optional) When set to either true, t or 1, each Tweet returned in a timeline
* will include a user object including only the status authors numerical ID.
* Omit this parameter to receive the complete user object.
* @param excludeReplies (optional) This parameter will prevent replies from appearing in the
* returned timeline. Using exclude_replies with the count parameter will
* mean you will receive up-to count tweets — this is because the count
* parameter retrieves that many tweets before filtering out retweets and
* replies. This parameter is only supported for JSON and XML responses.
* @param contributeDetails (optional) This parameter enhances the contributors element of the
* status response to include the screen_name of the contributor. By
* default only the user_id of the contributor is included.
* @param includeEntities (optional) The entities node will be disincluded when set to false.
*/
@GET("/1.1/statuses/home_timeline.json?" +
"tweet_mode=extended&include_cards=true&cards_platform=TwitterKit-13")
Call<List<Tweet>> homeTimeline(@Query("count") Integer count,
@Query("since_id") Long sinceId,
@Query("max_id") Long maxId,
@Query("trim_user") Boolean trimUser,
@Query("exclude_replies") Boolean excludeReplies,
@Query("contributor_details") Boolean contributeDetails,
@Query("include_entities") Boolean includeEntities);
The way I have to call this is
val homeTimeline = TwitterCore.getInstance().apiClient.statusesService.homeTimeline(100, 344796632681967616, Long.MAX_VALUE, true, false, false, false)
homeTimeline.enqueue(object : Callback<List<Tweet>>() {
override fun success(result: Result<List<Tweet>>) {
toast(result.data?.size.toString())
}
override fun failure(exception: TwitterException) {
toast(exception.message.toString())
}
})
Can anyone guide me if I am missing anything? Consumer and secret Keys are configured correctly as I can receive user timeline already.