Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph API - get custom profile picture size

I'm trying to get the logged in user's profile picture for a canvas app, but I would like to have it in a specific size.

Is this possible and, if so, how?

Currently I'm using the following:

graph.facebook.com/{user's FB ID}/picture?type=square

This gives me a 50px by 50px image. There are also options to use type=normal and type=large to give large image size, but these are not square images, and also not the exact size I am looking for.

To be specific, is there a way to get a member's profile picture in size 80px by 80px directly from Facebook, without downloading a larger image and downsizing/cropping on my end?

like image 779
sveti petar Avatar asked Nov 14 '14 16:11

sveti petar


People also ask

Is Facebook Graph API deprecated?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.

Is Facebook Graph API RESTful?

The Legacy REST API is in the process of being deprecated, while the Graph API is the most current, so if you're unsure of which one to use, your best bet is to go with that one. As you suggested, the Graph API, just like the Legacy REST API, is in fact a RESTful API.


2 Answers

You can use width/height as parameter:

graph.facebook.com/{user's FB ID}/picture?width=100&height=100

Just keep in mind that you may not get exact sizes, but very close ones.

like image 76
andyrandy Avatar answered Oct 20 '22 19:10

andyrandy


Getting a bigger facebook profile picture via facebook php sdk, this worked for me:

$response = $fb->get('/me?fields=picture.width(400).height(400)', getenv('FACEBOOK_ACCESS_TOKEN'));

in 2019!

like image 28
mangrove108 Avatar answered Oct 20 '22 20:10

mangrove108