PHP cURL表示不支持https

时间:2014-11-27 06:33:01

标签: php ssl curl

我正在向网页发出几个cURL请求。在这一个POST请求之后,我在cURL输出中得到了这个错误

* Protocol  https not supported or disabled in libcurl
* Closing connection -1

cURL甚至没有提出请求。我无法弄清楚如何解决这个错误。

奇怪的是,我的CLI和FPM都启用了SSL。在这里看到http://cl.ly/image/1L062C2h2M2W

我尝试将请求发送到http://而不是https://。这并没有改变任何事情。我甚至尝试确保我的服务器有SSL,而且没有改变它。

我的cURL电话看起来像这样

$fp2 = fopen('cookies/debug.txt', 'a');
fwrite($fp2, "\n $action");
fwrite($fp2, "\n $url");
fwrite($fp2, "\n ".sizeof($data));
fwrite($fp2, "\n ".json_encode($data));
fwrite($fp2, "\n_________________________________________\n");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($action == "POST") curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POSTREDIR, 3);

$fp = fopen('cookies/curl.txt', 'a');
curl_setopt($ch, CURLOPT_STDERR, $fp);

curl_setopt($ch, CURLOPT_COOKIEJAR, $this->strCookie);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $this->strCookie);

    if($header) {
        curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
    }

// Set the request as a POST FIELD for curl.
if($action == "POST") {

    if(in_array("Content-Type:application/x-www-form-urlencoded", $header)) {
        $data = http_build_query($data);
    }

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}

// Get response from the server.
$res = curl_exec($ch);
fwrite($fp, "\n_________________________________________\n");
fwrite($fp, "\n$action $url\n");

return $res;

并且最后一次调用的完整调试是

______________about to try___________________________
POST  https://sellercentral.amazon.com/gp/communication-manager/view-message.html/ref=ag_xx__cmread?ie=UTF8&addnFilter0=rs&arrivalDate=1417064517&clcmResponseTimeSuboptions=uwd&curPage=1&dateExactEnd=&dateExactStart=&dateFilter=7d&isInbox=1&itemsPerPage=20&marketplaceId=ATVPDKIKX0DER&messageId=A3OSG68VXPA9BV&msgIndex=1&otherPartyId=&pageNum=1&replyToEmail=0&searchBoxText=&showFilters=0&sortBy=ArrivalDate&sortOrder=Descending&timestamp=1417070427&totalMsg=1&view=reader

* Protocol  https not supported or disabled in libcurl
* Closing connection -1

"即将尝试",是我自己的调试。当我尝试这个请求时,这两个**是cURL的唯一输出。

1 个答案:

答案 0 :(得分:1)

“https”前面有一个空格。该错误表示不支持“https”。