1

MAC osX で php を有効にしましたが、通常の php コードは正常に動作しますが、今日は奇妙なエラーが 1 つ発生しました

<?php 
$hi = file_get_contents("https://ojooo.com");
echo $hi;
?>

上記のコードの場合、ローカルサーバーで以下のエラーが発生します.しかし、上記のコードは私のホスティングで正常に動作しています.

Warning: file_get_contents() [function.file-get-contents]: SSL operation failed with code 1. OpenSSL Error messages: error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) in /Library/WebServer/Documents/hi/index.php on line 2

Warning: file_get_contents() [function.file-get-contents]: Failed to enable crypto in /Library/WebServer/Documents/hi/index.php on line 2

Warning: file_get_contents(https://ojooo.com) [function.file-get-contents]: failed to open stream: operation failed in /Library/WebServer/Documents/hi/index.php on line 2

通常file_get_content(https://yahoo.com);は正常に動作しています。誰か助けてください

4

4 に答える 4

1

問題は、SSL(https) へのリダイレクトを呼び出そうとするこのサイトです。そして、php_openssl.dllモジュールが必要です。それ以外の場合は機能しません。

php.iniアクティブな検索行を編集します。

;extension=php_openssl.dll

コメントを外します。

編集:

phpinfo()を作成して、出力の上部を見ることができます。どのphp.iniファイルがロードされているかを確認できます。

于 2012-11-27T17:27:38.917 に答える
1

私は同じ問題を抱えていましたが、最終的file_get_contentscurl呼び出しに置き換えることで解決しました。

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
$content = curl_exec($curl);
curl_close($curl);
于 2014-05-22T09:57:33.517 に答える
0

OpenSSL を有効にする必要があります。

;extension=php_openssl.dll

削除する ;

extension=php_openssl.dll

あなたのphp.iniファイルで。

于 2012-11-27T17:26:28.303 に答える
-1

サーバーの SSL 証明書に問題があるようです。

$hi = file_get_contents("http://ojooo.com");代わりに使用

于 2012-11-27T17:25:25.600 に答える