Php 如何使用HTTPS获取站点内容
使用ssl(HTTPs)的站点的ex: 1-我试图使用文件内容获取其内容,但不起作用,给出错误 例:Php 如何使用HTTPS获取站点内容,php,curl,https,fopen,Php,Curl,Https,Fopen,使用ssl(HTTPs)的站点的ex: 1-我试图使用文件内容获取其内容,但不起作用,给出错误 例: 任何人都有任何想法???要从安全协议https获取内容,您需要从php.ini文件启用opensslextension,并为此启用身份验证。网站重定向301 更改url 从 到 或者如果仍然不工作或需要使用它/ 瞧 使用curl redirect rules可能重复您的答案如下:您可以按照建议在php.ini中启用openssl扩展 <?php $contents = file_get_c
任何人都有任何想法???要从安全协议
https
获取内容,您需要从php.ini文件启用openssl
extension,并为此启用身份验证。网站重定向301
更改url
从
到
或者如果仍然不工作或需要使用它/
瞧
使用curl redirect rules可能重复您的答案如下:您可以按照建议在php.ini中启用openssl扩展
<?php
$contents = file_get_contents("https://www.eb2a.com/");
echo $contents;
?>
<?php
$url = 'https://www.eb2a.com/';
$contents = fopen($url, 'r');
echo "$contents";
?>
function cURL($url, $ref, $header, $cookie, $p){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if ($p) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$result = curl_exec($ch);
curl_close($ch);
if ($result){
return $result;
}else{
return '';
}
}
$file = cURL('https://www.eb2a.com/','https://www.eb2a.com/',0,0,null);
echo $file
https://www.eb2a.com/
https://www.eb2a.com