本文详细记录了 PHP 使用 curl
遇到的问题。
GitHub:https://github.com/khs1994-php/curl
Windows Curl SSL
https://curl.haxx.se/docs/caextract.html
点击最新的日期,下载文件放到 c:\cacert-2018-03-07.pem
php.ini
增加如下配置
1 | curl.cainfo="c:\cacert-2018-03-07.pem" |
初始化
1 | $ch=curl_init(); |
设置网址
1 | curl_setopt($ch, CURLOPT_URL, $url); |
post
1 | curl_setopt($ch, CURLOPT_POST, 1); |
post 表单
1 | $data=[ |
https
1 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); |
htpasswd
1 | curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password); |