cache http://graph.facebook.com/[UID]/picture call?
Thanks to How can I display the users profile pic using the facebook graph api? I found out I can retrieve profile picture via
http://graph.facebook.com/[UID]/picture
but this redirects to an image like for example:
http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs1346.snc4/161671_1096373372_1486835_q.jpg
My first question is when I want to display this image should I do(returned from API)
<img src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs1346.snc4/161671_1开发者_如何学C096373372_1486835_q.jpg" />
or should I call the api:
<img src="http://graph.facebook.com/alfredwesterveld/picture" />
Does http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs1346.snc4/161671_1096373372_1486835_q.jpg show my updated profile picture, if update my profile picture on Facebook or does show my old profile picture. I ask these question because when I could call an absolute URL(which resolves to an image immediately) I could safe myself a redirect(round-trip). I believe this could add up especially when I want to get all profile pictures from the visitors of my website.
When you want to display the picture of a user use the second method, that's the good one:
<img src="https://graph.facebook.com/[UID]/picture" alt="" />
Doing like this you'll be sure that each time you'll receive the updated picture of the user, if it was changed recently.
later edit
Related to the cache issue, if you want to save the direct urls in order to improve caching of the pictures I don't suggest doing so because those urls are changing each time a user changes the profile picture, so you might end up displaying an older picture even though the user actually changed it recently.
hi why you not use fbml tag for this?
<fb:profile-pic uid='UID' width='50' height='50'></fb:profile-pic>
EDIT hello if you want to get photo uploaded by the user then you can get by this
$photos=json_decode(file_get_contents('https://graph.facebook.com/me/photos?access_token='.$cookie['access_token'])); foreach ($photos->data as $friend) { ?> <img src="<?=$friend->source?>" width="50" height="50"> <?php }
All images uploaded by the user can be easily captured
精彩评论