I am using file_get_contents() php function in my laravel 4.2 code to get profile photo after login through facebook .
it worked correctly when I use this
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=> false,
"verify_peer_name"=> false,
),
);
$content = file_get_contents($myurl, false, stream_context_create($arrContextOptions));
but it makes a security hole in the system as mentioned before in another question for the same issue , if I dont use this security hole method , error blows up in my face which I cannot handle
ErrorException (E_WARNING) HELP file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"
then I tried Curl method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$myURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$content = curl_exec($ch);
curl_close($ch);
file_put_contents($path, $content);
it didnot make any error and it did not work neither "no photo returned" ! so how can I get the profile photo in a secure clean way and save it using php (laravel 4.2) ?! I am testing it on my localhost using XAmpp
working code:
function taken from here: PHP Curl following redirects