slandau
slandau

Reputation: 24052

Facebook API Question

So in our database right now, we can store text, and text only. So, when a user comes to our site and makes a post, he/she can choose to have the post made along with their Facebook name (if they are connected through the Facebook API). If they say yes to that choice, we make an API call to get the Facebook /me object, and then make the call to the database with the response.name that comes back - text - fine.

Now, we reach another desired feature. We want to be able to show a users Facebook profile picture with their posts, once again, only if they choose to do so. Now, I know we can say, "Allow us to store your profile picture with this post", and then make some sort of API call to Facebook to get their image, and store this image as data, and load this up when we load up their post, however, we don't want to do that.

Is there a way we can reference each users profile picture by using their unique Facebook id? For example, in the database we store their Facebook id along with our messageId, can we then do something like (in Javascript):

function loadMessage(messageId, facebookId)
{
    // get their message from our database
    displayMessage(messageId);
    var imageTag = getFBProfilePic(facebookId);
    $('#container div:last-child').addImage(imageTag);
}

or something like that? I wasn't sure if there was a way that this was possible because, say you were logged in as someone, how can you make a FB.api request to get a profile picture using someone ELSE's facebookId? Can you?

Point is, we want to load pics tied to the poster (from their Facebook), dynamically through the Facebook API, instead of using our own storage to store the image files.

Upvotes: 1

Views: 107

Answers (2)

Ashfame
Ashfame

Reputation: 1759

You can use this URL for the profile picture - https://graph.facebook.com/ID/picture

Upvotes: 1

codeandcloud
codeandcloud

Reputation: 55200

If you do have the user ID, you can use fb:profile-pic ( FBML )
Link here: http://developers.facebook.com/docs/reference/fbml/profile-pic/

Upvotes: 0

Related Questions