cURL GET请求在本地返回结果,但是在生产时返回null?

时间:2016-06-15 16:57:01

标签: php post curl

我遇到了一个问题,我发现很难调试。对于我的项目,我使用cURL向公共API发出GET请求。在localhost上我收到结果,但是当我发布到生产时,结果是“null”。需要注意的一点是,我的项目没有SSL证书,但我连接的公共API有 - 。我不确定这是否有任何区别,但无论如何我都在提及它。

以下是我的请求示例:

public function latestArticles($count) {

    $ch = curl_init();  

    curl_setopt($ch,CURLOPT_URL,'http://public-api.com/LatestResults?count=' . $count);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


    $output=curl_exec($ch);

    if($output === false)
    {
        echo "Error Number:".curl_errno($ch)."<br>";
        echo "Error String:".curl_error($ch);
    }
    curl_close($ch);
    return $output;

}

0 个答案:

没有答案