无法通过HTTPS和cURL在PHP连接 [英] Failing to connect through HTTPS and cURL at PHP
本文介绍了无法通过HTTPS和cURL在PHP连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用 cURL
和 https
连接到API,我无法使用它。
I am trying to connect to an API using cURL
and https
and I don't get it work.
它与 http
完美配合,但当我将它改为 https
在 $ url
变量中,执行需要30秒以上,最后它显示 false
It work perfectly with http
but when i change it to https
in the $url
variable, it takes more than 30 seconds to execute and finally it shows false
as a result.
这是函数:
$url = 'https://api.xxxxxxx.com/api.php?user=xxxx&pass=xxxx';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
如果我用这个调试:
debug(curl_init($url));
我得到:
resource
任何可能是原因的想法?
Any idea which could be the cause?
推荐答案
结果是网站试图访问不允许安全连接。
It ended up to be that the website was trying to access didn't allow secure connections.
这篇关于无法通过HTTPS和cURL在PHP连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文