0

我有一个 PHP 脚本,它显示嵌入在我在本地计算机上构建的站点中的推文。当我将站点上传到我的 IIS 8.0 服务器时,PHP 脚本不再工作,并且我收到此错误:

警告:第 76 行 C:\inetpub\wwwroot\i360_new\footer.php 中为 foreach() 提供的参数无效

脚本是:

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


    /** Perform a GET request and echo the response **/
    /** Note: Set the GET field BEFORE calling buildOauth(); **/
    $url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
    $getfield = '?screen_name=interactive360&count=1';
    $requestMethod = 'GET';
    $twitter = new TwitterAPIExchange($settings);
    $string = json_decode($twitter->setGetfield($getfield)
    ->buildOauth($url, $requestMethod)
    ->performRequest(),$assoc = TRUE);
    foreach($string as $items)
        {
            echo $items['text']."<br />";
        }
?>

我认为这可能是 PHP 版本问题,但我的本地机器运行的是 5.4.10,而我的服务器运行的是 5.4.14。

4

1 回答 1

0

It turns out this was an SSL/CURL issue. In the TwitterAPIExchange.php file, I had to add these two lines to the CURL options array:

CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
于 2013-09-30T19:28:13.967 回答