1

I enabled php in my MAC osX and normal php codes works fine , but I got one strange error today

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

For the above code i get below error on my local server.But above code is working fine on my Hosting.

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 

the normal file_get_content(https://yahoo.com); is working fine.Please some one help me

0

4 Answers 4

1

The problem is this site you try to call redirects to SSL(https). And then you need the php_openssl.dll module. Otherwise its not working.

Edit your active php.ini find the line:

;extension=php_openssl.dll

and uncomment it.

Edit:

you can make an phpinfo() and look at the top of the output. There you can see which php.inifile is loaded.

Sign up to request clarification or add additional context in comments.

2 Comments

yea i opened php.ini file !! but do u know the shortcut to find text in terminal ??
Hey ,,now i get only blank file
1

I had same problem and i finally solved by replace file_get_contents with curl call.

$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); 

Comments

0

You have to activate OpenSSL.

;extension=php_openssl.dll 

Remove ;

extension=php_openssl.dll 

in your php.ini file.

2 Comments

search your php.ini file. run php --ini in your console
yea i opened php.ini file !! but do u know the shortcut to find text in terminal ??
-1

There appears to be a problem with your servers SSL certificate, if there is even supposed to be one.

Use $hi = file_get_contents("http://ojooo.com"); instead

1 Comment

Yea i changed, but still same error...But same code works fine in HOSTING...but not on my local server

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.