我尝试使用curl访问api并在非https站点获取输出,但我在https certify站点更新此代码但无法正常工作。我尝试过代码,如下所示,它在非https网站上工作。
$url = "http://45.116.113.98:8081/WebAP1/api/SchemeMast/1/40/WEBDTG100-/45/-/Prabakaran/S/-/4-44,pillaiyar%20kovil%20street,ko.thoppu%20vill,nochalu/-/Villupuram/Villupuram/Tamil%20Nadu/India/604201/9787162221/9787162221/0.000/100.00/2017-12-21/C";
$headers = array();
$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
curl_setopt($process, CURLOPT_HEADER, 0);
curl_setopt($process, CURLOPT_USERAGENT, $user_agent);
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
$return = curl_exec($process);
curl_close($process);
并且也尝试过这种方式,
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
但两者都无法在我的https网站上运行
你的问题在这里描述:
curl -i https://45.116.113.98:8081
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
和here
这意味着不支持HTTPS协议, 可能是因为网站未配置为支持HTTPS 或者你使用了错误的端口(默认情况下:http - > 80,https - > 443)。