【问题标题】:Does tweet_mode=extended work with the Twitter statuses/user_timeline API?tweet_mode=extended 是否与 Twitter statuses/user_timeline API 一起使用?
【发布时间】:2019-12-14 06:57:21
【问题描述】:

https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html 没有提及 tweet_mode

我想知道是不是我使用了错误的 API 才能利用 tweet_mode?

在我的应用程序中,我提供了 tweet_mode=extended 参数,但它没有任何效果。我的代码...

  // Load the Tweets.
  $args = array(
    'screen_name' => $username,
    'exclude_replies' => 'true',
    'include_rts' => 'true',
    'tweet_mode' => 'extended',
    'count' => $numitems,
  );

  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

  $tweets = $connection->get('statuses/user_timeline', $args);

  if (!empty($tweets)) {
    foreach ($tweets as $tweet) {
        $text = $tweet->full_text;
        // etcetera

【问题讨论】:

    标签: rest api twitter


    【解决方案1】:

    是的,您可以将 tweet_mode 与 statuses/user_timeline API 一起使用。不过,转推是一种特殊情况。检查 retweeted_status 对象,如https://dev.to/kehers/formatting-tweets-a-look-at-extended-tweets-retweets-and-quotes-n5j中所述

    简而言之,如果推文是转推,则必须在 $tweet->retweeted_status->full_text 访问扩展推文。因此,有必要在您的代码中检查每个推文对象是否具有 retweeted_status 属性。

    【讨论】:

      猜你喜欢
      • 2016-07-22
      • 1970-01-01
      • 2012-07-10
      • 2018-06-13
      • 2018-06-17
      • 1970-01-01
      • 2011-01-19
      • 1970-01-01
      • 2019-11-26
      相关资源
      最近更新 更多