3
EX網站:https://www.eb2a.com如何使用SSL(HTTPS)來獲取網站使用HTTPS內容
1 - 我嘗試使用的file_get_contents來獲得它的內容,但無法工作,給錯誤 例如:
<?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 - 我試圖使用捲曲,但無法正常工作,並給予空白頁 例如:
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
任何一個有什麼想法?
你會得到什麼錯誤? – 2010-05-21 07:11:00
[https://stackoverflow.com/questions/1975461/file-get-contents-with-https]的[file_get_contents可能的重複] – VolkerK 2010-05-21 07:22:32
你有這裏的答案:[如何獲取文件獲取-contents功與-HTTPS(http://stackoverflow.com/questions/1975461/how-to-get-file-get-contents-work-with-https) – Roberto 2016-04-14 12:40:58