Get user profile image by ID

Now I am working on a web application which is mainly based on facebook api graphics. I own some user data - in fact, publicly available data is available, such as name and identifier. I also know that the profile image is part of the publicly available data, and I wondered how I can get a direct link to the user profile image only with its identifier?

Thank you in advance

+108
facebook facebook-graph-api
Jul 11 '12 at 22:26
source share
12 answers

http://graph.facebook.com/ "+ facebookId +" / picture? type = square For example: http://graph.facebook.com/67563683055/picture?type=square

There are also more sizes besides the “square”. See documents .

+264
Jul 11 2018-12-12T00:
source share

You can use the following URLs to receive images of images of different sizes. Be sure to add the Facebook ID to the URL.

Large photo https://graph.facebook.com/ {facebookId} / picture? type = large

Medium sized image https://graph.facebook.com/ {facebookId} / picture? type = normal

Small photo https://graph.facebook.com/ {facebookId} / picture? type = small

Square photo https://graph.facebook.com/ {facebookId} / picture? type = square

+113
Jan 13 '14 at 4:45
source share

To get the maximum image size

https://graph.facebook.com/{userID}?fields=picture.width(720).height(720) 

or anything else you need as a size. Based on experience, type = large is not the biggest result you can get.

+36
Jan 16 '14 at 12:59 on
source share

This will be a useful link:

http://graph.facebook.com/893914824028397/picture?type=large&redirect=true&width=500&height=500

You can set the height and width as you need

893914824028397 - Facebookid

+16
Apr 20 '16 at 7:43
source share

This is literally on the first page of the Graph API documentation .

  • /OBJECT_ID/picture returns a redirect to the picture of the object (in this case, these are users)
  • /OBJECT_ID/?fields=picture returns the URL of the picture

Examples:

<img src="https://graph.facebook.com/4/picture"/> uses HTTP 301 redirection to Zuck's profile photo

https://graph.facebook.com/4?fields=picture returns the URL itself

+13
Jul 11 '12 at 22:32
source share

This API makes it easy to get fb, google and twitter profile photos here.

https://www.avatars.io/

This is an API that returns a profile picture when it is given a username for various social networks, including Twitter, Facebook, Instagram and Gravatar. It has libraries for iOS, Android, Ruby, Node, PHP, Python, and JavaScript.

+6
May 17 '17 at 16:42
source share

Use url like: https://graph.facebook.com/ user_id / picture? type = square in src of the img tag. the type may be small, large.

+3
Jul 18 '12 at 9:21
source share

You can use AngularJs for this, its two-way data binding will get the solution with minimal effort and less code.

<div> <input type="text" name="" ng-model="fbid"><br/> <img src="https://graph.facebook.com/{{fbid}}/picture?type=normal"> </div>

I hope this answers your request. Note. You can use another library.

+2
Jun 12 '17 at 0:28
source share

You can get it using this URL: you will get an HD image (maximum size)

 https://graph.facebook.com/{userID}?fields=picture.width(720).height(720)&redirect=false 

don't forget redirect = false, otherwise it will return an error

+2
Jul 04 '18 at 15:06
source share

Using the Javascript SDK (v2.12 - April 2017), you can get detailed information about the image request as follows:

 FB.api("/" + uid + "/picture?redirect=0", function (response) { console.log(response); // prints the following: //data: { // height: 50 // is_silhouette: false // url: "https://lookaside.facebook.com/platform/profilepic/?asid=…&height=50&width=50&ext=…&hash…" // width: 50 //} if (response && !response.error) { // change the src attribute of img elements [...document.getElementsByClassName('fb-user-img')].forEach( i => i.src = response.data.url ); // OR redirect to the URL above location.assign(response.data.url); } }); 

To get a JSON response, the redirect parameter is important with 0 (zero) as the value, since by default the request redirects the image. You can add other parameters to the same URL. Examples:

  • "/" + uid + "/picture?redirect=0&width=100&height=100" : a 100x100 image will be returned;
  • "/" + uid + "/picture?redirect=0&type=large" : a 200x200 image is returned. Other possible type values ​​include: small, normal, album, and square.
+1
Apr 17 '18 at 16:11
source share

Just follow as below url

https://graph.facebook.com/facebook_user_id/picture?type=square

The type can be normal, small, medium, large. Or a square (if you want to get a square image, the size of the square is limited to 50x50).

+1
Oct 29 '18 at 5:31
source share

According to the current latest version of the Facebook Facebook API API 3.2, for users you can use this general method to get a profile picture: https://graph.facebook.com/v3.2/ enjuser-id ‹/ picture? type = square, which you can visit the user picture documentation here . Possible values ​​for the type parameter in the URL can be small, normal, landscape, large, square

For groups and pages , the profile image is not directly accessible. You must get them using an access token. For groups, you must use a user access token, and for pages you can use both a user access token and a page access token.

Can you get a profile picture of a group or page using a common URL: https://graph.facebook.com/v3.2/ enjuser-id ‹/ picture? access_token = enjaccess-tokencasts & type = square

I hope this is useful for people who are looking for a page image or group profile.

+1
Feb 20 '19 at
source share



All Articles