我正在尝试使用Twitters API来检索一个hashtagged结果列表 – 它曾经非常简单,因为它们不需要身份验证,但现在它对我来说变得棘手……
我已经关注了这篇文章https://stackoverflow.com/questions/12916539/simplest-php-example-for-retrieving-user-timeline-with-twitter-api-version-1-1/15314662#=
但是当我加载我的页面时它只显示NULL – 我相信我已经完成了所有事情
注意 – 下面的PHP文件与文件TwitteraPIExchange位于同一目录中
帮助将不胜感激
<?PHP
ini_set('display_errors', 1);
require_once('TwitteraPIExchange.PHP');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "xxxxx",
'oauth_access_token_secret' => "xxxxx",
'consumer_key' => "xxxxx",
'consumer_secret' => "xxxxx"
);
$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?screen_name=j7mbo';
$requestMethod = 'GET';
$twitter = new TwitteraPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
var_dump(json_decode($response));
?>
解决方法:
添加CURLOPT_SSL_VERIFYPEER =>对于TwitteraPIExchange.PHP中的performRequest()方法中的CURL选项,为false.这似乎解决了它.
cf here