I am creating an app where a lot of facebook friends are loaded once the user is logged in. Then the app shows a list of these users where I want to show a small square profile picture next to each user.
I found this url to do that:
http://graph.facebook.com/4/picture?type=square
by checking the app, all data is loaded within 1 second, but it takes almost 10 to 20 seconds to show all images because of the url translation from graph.facebook.com to the original url.
so I went checking the manuals, and found more info regarding receiving the url as JSON, what I could use in PHP to store the direct url of that square picture, so it will not be translated every time I reload the app.
so the next url gives me that JSON:
http://graph.facebook.com/4/picture?type=square&redirect=false
this url will give me this as output in my browser:
{
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/p50x50/10390028_10102210419817761_5871103530921178170_n.jpg?oh=8113088106568f3a88016bcf414ba67f&oe=56C5FA23&__gda__=1455882568_659558fb576ed2425347df8a208cbca4"
}
}
the next step was to get the url out of that JSON, what I try to do using this code
$url = 'http://graph.facebook.com/4/picture?type=square&redirect=false';
echo json_decode(file_get_contents($url))->url;
the strange thing is now, after a lot of trial & error, everytime I use file_get_contents, all ECHO text is gone, even if I do somewhere something like echo "test" , that echo is also gone. Even if I store that output to a variable, it is still empty. Can anyone show me what I do wrong? thank you.
The goal is.. once the user is logged on.. to store username, user id and the url to that square user picture in a temporary location until the session is broken, just to get the load performance better