时时商务社区

标题: php使用curl获取https请求的方法 [打印本页]

作者: yj1281    时间: 2018-2-14 05:49

            本文实例讲述了php使用curl获取https请求的方法。分享给大家供大家参考。具体分析如下:
今日在做一个项目,需要curl获取第三方的API,对方的API是https方式的。
之前使用curl能获取http请求,但今天获取https请求时,出现了以下的错误提示:证书验证失败。
SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed  
解决方法为在curl请求时,加入:
[U]复制代码[/U] 代码如下:curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查  
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);  // 从证书中检查SSL加密算法是否存在
curl https请求代码
[U]复制代码[/U] 代码如下:'fdipzone');  
$header = array();  
  
$response = curl_https($url, $data, $header, 5);  
  
echo $response;  
?>
希望本文所述对大家的php程序设计有所帮助。
            
            
您可能感兴趣的文章:
  • php抓取https的内容的代码
  • 如何使用php判断服务器是否是HTTPS连接
  • php使用curl访问https示例分享
  • php之curl实现http与https请求的方法
  • PHP实现抓取HTTPS内容
  • php中http与https跨域共享session的解决方法
  • php curl 获取https请求的2种方法
  • php使用curl打开https网站的方法
  • PHP中file_get_contents函数抓取https地址出错的解决方法(两种方法)
  • PHP抓取HTTPS内容和错误处理的方法
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2