LironXYZ LironXYZ - 6 months ago 23
PHP Question

PHP - Retrieve Facebook image in Google Compute Engine

I've tried to retrieve the image data of my Facebook profile picture, using both file_get_contents and curl.

The problem occurs on my Google compute engine instance, while on any other server (localhost - mamp, AWS) the script works fine.

An example for one of the scripts I was using



Please keep in mind that I've tried using the parameter redirect=false, and accessing the image url I've got in my json response returned false as-well.

Also, I've tried using wget in SSH to the image's url, which returned (403) Forbidden.

My assumption is that I need to configure something differently in my server, not PHP, but because I'm able to retrieve any other image, with the same script - I'm not sure what.


I've already experienced this exact problem, Ignoring SSL verification while using cURL did the trick for me.

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Ignore SSL verification
curl_setopt($ch, CURLOPT_URL, "");
$data = curl_exec($ch);