Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Last active October 22, 2023 15:09
Show Gist options
  • Select an option

  • Save hsleonis/36757e4da75516a60140c5b9a5b156ac to your computer and use it in GitHub Desktop.

Select an option

Save hsleonis/36757e4da75516a60140c5b9a5b156ac to your computer and use it in GitHub Desktop.
Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to “Allow” the application)
Basic: (50x50 pixels)
<img src="//graph.facebook.com/nusraatfariaofficial/picture">
Square:
maximum width and height of 50 pixels.
Small
maximum width of 50 pixels and a maximum height of 150 pixels.
Normal
maximum width of 100 pixels and a maximum height of 300 pixels.
Large
maximum width of 200 pixels and a maximum height of 600 pixels.
<img src="//graph.facebook.com/nusraatfariaofficial/picture?type=large">
You can specify the height and width:
<img src="//graph.facebook.com/nusraatfariaofficial/picture?width=140&height=110">
It will return a JSON response if you're using one of the Facebook SDKs request methods.
Otherwise it will return the image itself.
* To always retrieve the JSON, add:
&redirect=false
Example: graph.facebook.com/nusraatfariaofficial/picture?type=large&redirect=false
Response:
{
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/hprofile-xpt1/v/t1.0-1/p200x200/12804615_1759832994236748_7994254082136289991_n.jpg?oh=247525e33c07520415207982fdd8cdfa&oe=578CF6EB"
}
}
@azickri
Copy link
Copy Markdown

azickri commented Oct 5, 2023

Thanks

@ZaneCEO
Copy link
Copy Markdown

ZaneCEO commented Oct 22, 2023

Please note that this DOESN'T WORK for users. It only works for PAGES, like the on you're using as the example.

If you want to get a user profile picture, you need his/her user ID and an access_token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment