Twitter OAuth:用户/搜索有效,但搜索/推文无效 [英] Twitter OAuth: users/search works but search/tweets does not
问题描述
我想在 Twitter 中搜索推文.它不起作用.
I want search for tweets in twitter. It is not working.
$parameters = array('q' => 'oauth');
$result = $connection->get('search', $parameters);
但是当我进行用户搜索时,它运行良好.
But when I do a user search it working perfectly.
$parameters = array('q' => 'oauth');
$result = $connection->get('users/search', $parameters);
我也尝试了以下方法,但也不起作用
I have also tried the below and that is also not working
$parameters = array('q' => 'oauth');
$result = $connection->get('search/tweets', $parameters);
可能是什么原因?
错误信息
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)
)
)
推荐答案
您似乎正在使用 Abraham Williams 的图书馆 TwitterOAuth.
You seem to be using the library TwitterOAuth by Abraham Williams.
我知道这是一个老问题,但我刚刚遇到了与 OP 相同的问题,并且它可能会继续发生在其他任何人身上,因为显然这个库已经有一段时间没有更新了.
I know this is an old question but I have just had the same problem as OP and it might keep happening to anyone else since apparently this library has not been updated for a while.
问题似乎在于 Twitter 不再通过其 API 的第 1 版接受请求.您必须按如下方式更改文件 twitteroauth.php
中的 $host
变量:
The problem seems to be that Twitter is no longer accepting requests via the version 1 of their API. You have to change the $host
variable in the file twitteroauth.php
as follows:
/* Set up the API root URL. */
//public $host = "https://api.twitter.com/1/";
public $host = "https://api.twitter.com/1.1/";
这篇关于Twitter OAuth:用户/搜索有效,但搜索/推文无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!