php - Twitter API - 显示多个指定用户的最新推文
问题描述
我想知道是否可以显示我指定的多个 Twitter 用户的最新推文。
这就是我删除键后的结果,它们确实在我的实际代码中定义:
<?php
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?user_id=McDonalds,Wendys,Dominos&count=1';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();
echo '<pre>';
$response = var_dump(json_decode($response));
但它只输出我最新的推文。我怎样才能使它输出指定用户的最新推文?
解决方案
有两种方法可以做到这一点 - 都不是你想要的那么简单。
首先,您可以单独为每个用户请求用户时间线。
所以打电话https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=McDonalds
,然后https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=Wendys
等等。
那可能很慢。因此,或者,您可以创建一个包含所有要关注的用户的列表。
然后,您可以使用 List API获取这些用户的所有最新推文。
推荐阅读
- symfony - 如何将实体数组传递给实体存储库并运行“在哪里”查询?
- mysql - 如何在一个 mysql docker 容器中启动多个实例
- firebase - 使用 Firestore 进行过滤和排序
- vespa - NO_SPACE - enumStoreLimitReached - 使用的枚举存储地址空间
- c# - Automapper 查找未映射的属性
- jquery - 仅针对具有 CSS 选择器的类的第一次出现
- javascript - javascript中的简单正则表达式在不应该返回true时返回
- java - Spring Boot - MockMVC 错误创建 bean
- python - 如何在 GtkSource 中选择和滚动特定行
- auth0 - 有没有办法在 auth0 规则中获取用户的语言?