rest - tweet_mode=extended 是否与 Twitter statuses/user_timeline API 一起使用?
问题描述
在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
解决方案
是的,您可以将 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 属性。
推荐阅读
- javascript - 任何人都可以解释为什么我收到此错误消息'Missing; 在 for 循环初始化程序之后'
- sql - 从视图中提取的日期过滤不起作用
- javascript - Google auth - 允许用户切换帐户
- jquery - Select2 组选择。值 当鼠标悬停在值上时自动跳到顶部
- php - 列出所有项目并突出显示给定类别中的项目
- django - Django DJANGO_SETTINGS_MODULE 在 Cookiecutter 中变回 'config.settings.local'
- docker - 当我在 Dockerfile 中使用 root 用户时构建图像报告“需要是 root”
- ios - 领域:- 由于未捕获的异常“RLMException”而终止应用程序?
- css - 视频应触及盒子的顶部和底部
- firebase - Firestore 安全规则 - 获取集合时 {wildcard} 既不为空也不为空