0
votes

I am getting following error when using PHP get_contents():

What am i missing here? It work perfectly in Local Server with XAMPP.

PHP Version 5.3.29

SSL Version OpenSSL/0.9.8b

Warning: file_get_contents() [function.file-get-contents]: SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure in /home/XXXXXX/public_html/test.php on line 21

Warning: file_get_contents() [function.file-get-contents]: Failed to enable crypto in /home/xxxxx/public_html/test.php on line 21

Warning: file_get_contents(https://.....XXXXXX) [function.file-get-contents]: failed to open stream: operation failed

$url_api        = "XXXXXXXXXXXXXX";

$getResult = array( 
"ssl" => array( 
    "verify_peer"      => false, 
    "verify_peer_name" => false, 
),  
'http'=>array(
    'method'=>"GET",    
    'header'=>"XXXXXX: xxxxxxxxxx\r\n"  
));
$getContext = stream_context_create($getResult);
$getResponse = file_get_contents($url_api, false, $getContext);
2
do you have openssl extension installed for your php?SLY
YES! OpenSSL support enabled I found it in phpinfo(). I added PHP version above... Is it because of lower php version? I tested with CURL and it never get any info returned. :)Vijay
allow_url_fopen is On?SLY
YES it is on for both Local and Master Value.Vijay
Not so sure, but here is the similar bugSLY

2 Answers

-1
votes

I don't think that the problem is in your code. I tested it on my Laravel vagrant box and it worked perfectly. I think that the problem is in the data of your $url_api variable.

-1
votes

Check your php.ini file, uncomment

;extension=php_openssl.dll

to

extension=php_openssl.dll

If this already been done, check your firewall if it allows the connection. Simple way is to use telnet.