TwitterAPIExchange'无法连接到主机'

时间:2016-04-26 10:52:07

标签: php twitter

我正在尝试使用TwitterAPIExchange搜索Twitter,但它 出现以下错误:

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攻击,所以我遵循了其他stackoverflow问题中的建议并添加了curl选项 CURLOPT_SSL_VERIFYPEER =>是的,但结果没有改变。

所以我不明白我的剧本有什么问题。

<?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);
?>

1 个答案:

答案 0 :(得分:0)

问题是托管上缺少curlCSS ......代码很好。

相关问题