【发布时间】:2014-05-24 02:39:13
【问题描述】:
decode我正在尝试在 php.ini 中搜索包含某个主题标签的推文。我正在使用推荐的代码,但我一直没有从中得到任何结果。这是我用来尝试获取结果的代码。
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$requestMethod = 'GET';
$getfield = '?q=#ManUtd&result_type=recent';
// Perform the request
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
我也试过了:
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$requestMethod = 'GET';
$getfield = '?q=#ManUtd&result_type=recent';
// Perform the request
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
var_dump(json_decode($response));
我仍然得到相同的结果。任何人都知道为什么我没有从中得到任何数据
【问题讨论】:
-
您确定您的
$settings正确吗?您是否尝试过不带标签搜索ManUtd(我不确定这是否会造成问题) -
是的,$settings 与我用于其他事情的设置相同,它们都可以工作。我在 TwitterAPIExchange 中没有碰过任何东西,但我猜这一切都是正确的
-
当您对
#进行 URL 编码时会发生什么情况,所以它是%23? -
当我使用 $getfield = '?q=%23ManUtd&result_type=recent';
-
嗯,只需先进行常规调试,然后了解您的问题。 blog.teamtreehouse.com/how-to-debug-in-php