我正在尝试使用以下代码从网站检索数据(我已经审查了网址):
<?PHP $url = [doesnt really matter]; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); $archivo_xml = fopen("test.tst","w"); curl_setopt($ch,CURLOPT_FILE,$archivo_xml); curl_exec($ch); $as1 = curl_getinfo($ch,CURLINFO_NAMELOOKUP_TIME); $as2 = curl_getinfo($ch,CURLINFO_CONNECT_TIME); $as3 = curl_getinfo($ch,CURLINFO_PRETRANSFER_TIME); $as4 = curl_getinfo($ch,CURLINFO_STARTTRANSFER_TIME); $as5 = curl_getinfo($ch,CURLINFO_TOTAL_TIME); echo "Lookup: ",$as1," \n\r Connect: ",$as2," \n\r Pretransfer: ",$as3," \n\r Starttransfer: ",$as4," \n\r Total: ",$as5,"\n\r","Error: ",curl_error($ch),"\n\r"; curl_close($ch); fclose($archivo_xml); ?>
它在本地工作正常,但不在服务器中.这是本地的输出:
Lookup: 0.015155 Connect: 0.0281 Pretransfer: 0.129087 Starttransfer: 0.786341 Total: 0.786384 Error:
这是服务器的输出:
Lookup: 0.028731 Connect: 0.043182 Pretransfer: 0 Starttransfer: 0 Total: 60.057787 Error: Unknown SSL protocol error in connection to [censored url]
任何其他网址工作得很好,问题是这个特定的.
localhost PHP版本:5.4.23
服务器PHP版本:5.5.7
提前致谢
尝试设置cURL参数
curl_setopt($ch,CURLOPT_SSLVERSION,3); // Apparently 2 or 3