0
我试图用TwitterAPIExchange来搜索Twitter,但它 提供了以下错误:TwitterAPIExchange“无法连接主机”
Fatal error: Uncaught exception 'Exception' with message 'couldn't
connect to host' in [...]/TwitterAPIExchange.php:305 Stack trace: #0
[...]/tweet.php(19): TwitterAPIExchange->performRequest() #1 {main} thrown
in [...]/teamwatch/TwitterAPIExchange.php on line 305
在这个阶段,我真的不关心MITM攻击,所以我按照在其他计算器问题中找到的建议,并添加了curl选项 CURLOPT_SSL_VERIFYPEER => false,但结果没有改变。
所以我不明白我的脚本有什么问题。
<?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/search/tweets.json';
$getfield = '?q=%40twitterapi';
$requestMethod = 'GET';
$options = array(CURLOPT_SSL_VERIFYPEER => false);
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(true, $options);
?>