1

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.

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I think that's similar to the other response, but my MAIN question is, what if the ID I pass into the URL, is not the same ID of the logged in user?
0

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/

3 Comments

So I can pass any id, not even the user that's currently logged in, and it will show?
No. You need to have an access token. see the call being made on the test console. api.facebook.com/method/fb:profile-pic?access_token=...
That I do know, what I meant was - if a user is logged into Facebook through my site, has an access token and everything, but requests the image tag with a userId that is of someone ELSE, but not theres, it will render?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.