1

我正在使用TwitterKit的一些 api 。我想获取用户的主页时间线,用户将在其中看到他的关注者的推文列表。如果我们查看主页时间线的 api 文档,参数是可选的。现在 twitter 工具包提供了所有必需的东西。我找到了仅通过 Twitter 工具包访问主时间线 api 的方法,但问题是它总是返回 400。如果您注意到即使参数是可选的,我也必须传递它们。找到下面的代码。

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);

我必须这样称呼它的方式是

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())
            }
        })

如果我遗漏任何东西,谁能指导我?消费者和密钥配置正确,因为我已经可以接收用户时间线。

4

0 回答 0