Reputation: 23
I've had a look through Facebook's online documentation and cannot find a way to manually construct a Facebook user's profile picture Uri using the user's third party ID (third_party_id
) field.
For example (doesn't work):
https://graph.facebook.com/<FACEBOOK_THIRD_PARTY_ID>/picture?type=square
http://developers.facebook.com/docs/reference/api/user/
third_party_id: An anonymous, but unique identifier for the user; only returned if specifically requested via the fields URL parameter
Using the user's Facebook ID to retrieve their profile picture image Uri works:
https://graph.facebook.com/<FACEBOOK_ID>/picture?type=square
For example (works):
<img src="https://graph.facebook.com/568916752/picture?type=square" />
Using the user's Facebook username to retrieve their profile picture image Uri works:
https://graph.facebook.com/<FACEBOOK_USERNAME>/picture?type=square
For example (works):
<img src="https://graph.facebook.com/brett.scott/picture?type=square" />
Best practices suggests that I store the user's third_party_id
instead of the user's Facebook ID (id
) in my database. I shouldn't be publicising a user's Facebook ID to other user's of my website. The reason? Because once a user can see another user's profile picture Uri, which contains their Facebook ID, they can find the other person's profile (see example below). I'm sure there's other reasons too.
Load profile picture:
https://graph.facebook.com/brett.scott/picture?type=square
- or -
https://graph.facebook.com/568916752/picture?type=square
Then any user can load the above user's profile:
http://www.facebook.com/brett.scott
- or -
http://www.facebook.com/568916752
I do not want to make a request using the Facebook Graph to obtain each user's profile picture Uri picture
because it's too slow. If there are 20 Facebook pictures on a page, that's 20 HTTP requests back to Facebook's servers. I'm aiming for zero.
Is there another way to obtain a Facebook user's profile picture using their third_party_id
or is it a missing feature?
https://graph.facebook.com/<FACEBOOK_THIRD_PARTY_ID>/picture?type=square
For example (third_party_id
generated for my application):
https://graph.facebook.com/0u0JrPIriHa3fgEDostj7v8dbdo/picture?type=square
Upvotes: 2
Views: 1608
Reputation: 11852
The Third Party ID is a unique, but anonymous identifier. It is meant to allow an advertiser to track unique users. It is specifically designed to NOT be resolvable to a Facebook ID.
For your site, you can store Facebook user ids in your database without violating the TOS, so long as you keep that data private.
When you request a photo from the Graph API, Facebook returns a CDN URL to the photo. You can publish that URL. You aren't supposed to store this data for longer than would be expected in a cache.
To get 20 pictures in one call, you can call the endpoint:
https://graph.facebook.com/picture?type=square&ids=UID_1,USERNAME_2,...UID_n
Upvotes: 1