4

使用 ssl (HTTPs) 的站点前:https ://www.eb2a.com

1 - 我尝试使用 file_get_contents 获取其内容,但不起作用并给出错误 ex:

<?php
$contents = file_get_contents("https://www.eb2a.com/");

echo $contents;
?>

2 - 我尝试使用 fopen,但不工作并给出错误 前:

<?php
$url = 'https://www.eb2a.com/';
$contents = fopen($url, 'r');
echo "$contents";
?>

3 - 我尝试使用 CURL,但不工作并给出空白页 ex:

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

任何人有任何想法?

4

2 回答 2

1

要从安全协议中获取内容https,您需要openssl从 php.ini 文件中启用扩展并为此进行身份验证。

于 2010-05-21T07:10:53.250 回答
0

网站重定向301

更改网址

https://www.eb2a.com/

https://www.eb2a.com

或者如果仍然无法工作或需要与 / 一起使用

链接

使用 curl 重定向规则

于 2020-04-19T06:52:13.180 回答