gpt4 book ai didi

php - 服务器出现 curl "Unknown SSL protocol error in connection"错误,但在本地有效

转载 作者:可可西里 更新时间:2023-11-01 12:25:24 28 4
gpt4 key购买 nike

我正在尝试使用以下代码从站点(我已经审查了 url)检索数据:

<?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]

任何其他 url 都可以正常工作,问题出在这个特定的 url 上。

本地主机 PHP 版本:5.4.23

服务器PHP版本:5.5.7

提前致谢

最佳答案

尝试设置 cURL 参数

curl_setopt($ch, CURLOPT_SSLVERSION,3); // Apparently 2 or 3

关于php - 服务器出现 curl "Unknown SSL protocol error in connection"错误,但在本地有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20988782/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com