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.
Why don't you just use the id you've already retrieved and display the image directly? Why do you need to make an extra call?
e.g
For example http://graph.facebook.com/4/picture?type=normal redirects to Mark Zuck's picture
If you're having trouble log the url out to make sure you're getting a valid id back and paste the url into a browser.
I have tried this and this is running successfully. Try this :
Hope You got the answer.
Try Like
This will give you the Link of the image and you can use it appropriately
One More Option
You Can Try These Example:
It should not be response.data.url....Try with response.picture.data.url