I am trying to fetch profile picture from facebook. Right now I am getting all information from facebook but unable to get profile pic of the user. Here is my code:
function getFBData () {
FB.api('/me', function(response) {
fbinfo = new Array();
fbinfo[0] = response.id;
fbinfo[1] = response.first_name;
fbinfo[2] = response.last_name;
fbinfo[3] = response.email;
FB.api('/me/picture?type=normal', function (response) {
var im = document.getElementById("profileImage").setAttribute("src", response.data.url);
alert(im);
});
How can I get picture from response of this API.
You can follow instruction from this link > https://developers.facebook.com/docs/facebook-login/web/
when you try to get response from profile by default you gonna get only
id
andname
but if you want to get
email
andpicture
you need to add parameter like thistry this:
I know this post is old, but the other answers are giving my website broken links (concatenating the user ID with the rest of the URL to get the image).
I found that the correct way to do this is as follows (according to the official docs here: https://developers.facebook.com/docs/graph-api/reference/user/picture/):
From the official docs, the way you get the profile picture of a user
@hiraa is right, but the code is missing. Here it goes