I am building Facebook profile picture scraper and using Phasher class to convert scraped pictures to Hexadecimal values and store it inside the database to compare it for similar pictures, Now I was using this http request to fetch for the pictures and it was working very well till the latest update for the Graph API v2.5
graph.facebook.com/'.$fid.'/picture?width=378&height=378
Or
graph.facebook.com/'.$fid.'/picture?type=large
you can change '.$fid.' to user id example for Mark account:
graph.facebook.com/4/picture?width=378&height=378
As you can see, It gave me Mark Zuckerberg's account picture.
It's not working now, I made a simple search I noticed that they changed the API in v2.5 to use access token so I created an application to give me App id and App secret to use it in the access_token=
as you can see in this line: graph.facebook.com/[ID]/picture?width=378&height=378&access_token=
Now when I use access token it's not working it was before giving me the scraped pictures inside avatar folder and hashed values inside database now it gives me 0 bytes pictures and it's blank.(Strange thing when I started the scraper it's scraped 184 and 249 profile pictures of the 300 scraped pictures)
I need to know why this happened ?
You can look at the full code on my Github account: github.com/jadolyo/FBpp
Any suggestions are welcomed too, Thanks.
http://php.net/manual/en/migration56.openssl.php
An official document describing the changes made to open ssl in PHP 5.6 From here I learned of one more parameter I should have set to false: "verify_peer_name"=>false
So my working code looks like this:
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$img = file_get_contents('https://graph.facebook.com/'.$fid.'/picture?width=378&height=378', false, stream_context_create($arrContextOptions));