4

ssl (HTTPs) を使用するサイトの例: https://www.eb2a.com

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 - 私は CURL を使用しようとしましたが、動作せず、BLANK PAGE 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

secure protocalからコンテンツを取得するには、php.ini ファイルから拡張機能を有効にし、そのための認証を行うhttps必要があります。openssl

于 2010-05-21T07:10:53.250 に答える