我有一个小页面,可以使用 twitter api 来获取某些用户的最新帖子并将其显示在网页上,但自上周以来我不再工作了。
它使用的是 James Mallison 的旧 TwitterAPIExchange,并使用 twitter api 1.1。
我尝试更改为 Abraham\TwitterOAuth,但我无法完成这项工作,当我尝试获取用户时,我不断收到“客户端未注册”错误...
在 Twitter 开发者部分中,似乎一切都很好,除了一件事......我正在使用似乎非常有限的免费选项,这可能是原因吗?或者我可能做错了什么?
如果可以的话请帮忙。
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret, $bearer_token);
$connection->setApiVersion('2');
$response = $connection->get('users', ['ids' => ****]);
print_r($response);
结果:
stdClass Object
(
[client_id] => ******
[detail] => When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.
[registration_url] => https://developer.twitter.com/en/docs/projects/overview
[title] => Client Forbidden
[required_enrollment] => Appropriate Level of API Access
[reason] => client-not-enrolled
[type] => https://api.twitter.com/2/problems/client-forbidden
)
twitter 的新所有者限制了 twitter 免费 api 访问,并且还弃用了一些 api v1.1 功能。