2016-04-26 149 views
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); 
?> 

回答

0

問題是主機上沒有curlCSS ...代碼沒問題。