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 Facebook ID:
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 Facebook Username:
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" />
Facebook Third Party ID:
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
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
Related
Goal
My goal is for a user to share something he created on my site to Facebook, and for me to display all comments on my own page using the Facebook comments plugin.
So my ideal flow would be:
User creates content with example id vjrjf834fdkfj, and shares using public URL http://example.com/vjrjf834fdkfj/.
User shares this URL on Facebook via my Facebook app ID. The post ID is 1234567.
I get this post ID. (This is what I need help with)
I store this in my database.
Whenever a visitor visit the page http://example.com/vjrjf834fdkfj/ I look up in the database what the post ID is (1234567 in this example), and call the Facebook comments plugin using this post ID.
What I tried
Attempt #1
First failed attempt: read the post_id field of the FB.ui callback but this response is typically empty because Facebook says that:
Only available if the user is logged into your app using Facebook and
has granted publish_actions. If present, this is the ID of the
published Open Graph story.
My user is not always logged into my app via Facebook, because he can also create a normal account.
Attempt #2
So my next attempt was to get a list of all posts of this app by calling the Graph API. I have a "basic" app with the "Website" platform set to my website URL (www.example.com). Given this list I might filter this on the relevant URL and voila, get the post ID for the right URL.
I can create an access token and call https://graph.facebook.com/v2.8/{app-id}/objects?access_token={token}, but this gives an error The parameter type is required. And when I try to get a list of object types by calling the /object_types endpoint, I get an empty list.
Attempt #3
I also played a bit with creating a Page Tab but the documentation makes no sense to me as to how that would apply to my case. I ended up with two extra pages, all empty, and not what I want. However, I could live with an extra page on my Facebook page showing a list of all posts that have been shared (so these posts would appear here and on my user's timeline).
Questions
So:
Why is this object_types list empty? I expect that something like "post" would show up here, allowing me to get a list of all posts associated with this app ID.
If this is not possible, how can I still achieve my end goal?
Thanks.
When exploring the Facebook Graph API, at: https://developers.facebook.com/tools/explorer The default example is get my name & id (under the assumption the browsers logged to my Facebook account). All good and I get my correct Id (facebook.com/id redirect to my profile).
So here is the thing: Exploring network traffic via developer console, I noticed some ajax have user id as url param, and the id is totally different from the previous one:
Same length
Much more zeros
So I tried same thing: facebook.com/new_id and same result: Redirect to my correct profile page.
How is that each user have 2 different id's?
It’s called app-scoped user ids, see https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api
I can get the details of the app using app id and Graph API.
e.g https://graph.facebook.com/2439131959/insights/application_active_users?since=1329724800&until=1329984000
However, is there any way to get the list of apps and their id so that I can use above query with access-token to get the app info?
Facebook User Object has the connection object called "accounts". Using this can get the facebook apps and pages owned by the current user. In order get these details via graph api, you need "manage_pages" permissions. This will return array of objects containing account name, access_token, category and id.
https://graph.facebook.com/me/accounts
checkout fb documentation
I am working on a project where a photo is taken and the user can share their photo on Facebook. We would use oAuth and the FB Graph API to post the photo and caption to the users' timeline. The client just made a request to also post it to their (the client's) photo album as well. So when the user submits a photo, it would post to the user's timeline as well as the client's timeline/album. Is this double post (to two different accounts) possible? Wouldn't that require that the client be logged in via oAuth as well? Also, are there any FB legal/regulation issues with this so long as the application has a disclaimer that it will be posted to two different places?
The entry for the user is a new photo to the apps album for that user. me/photos
However the entry that goes to your clients page... I don't think people can do id/photos of others or pages. (it's worth a shot)
You'll have to stick to id/feed and perhaps include a link to an image host.
I have a client who wants to use their Facebook photos in an iPhone app. We want to embed their account into the app so that when people download the app, they see the client's Facebook photos. The user should not need to login or connect to Facebook.
This is different than the standard "connect to facebook so we can access you data" - we have no need to access the users data.
Do I need to create a Facebook App, connect the client's Facebook account to the Facebook app, then use that to get the photo data ?
Ok, here is what I found
My business page is http://www.facebook.com/pages/Feltpad-Web-Mobile/128861547181352
That number at the end (128861547181352) is the business' "Facebook Graph ID"
Then use the Business Graph ID and go to http://graph.facebook.com/128861547181352/albums and you will see a list of all of the Photo Albums associated with the business' page. There is only one album, so that is all the info you get. The first valuable line on that page says "id": "133208113413362" - this is the Facebook Graph ID for the album.
Then use the Album's Graph ID and go to http://graph.facebook.com/133208113413362/photos - this will give you a JSON file with all the data you need for all the photos in the album.
You can also use ?limit=25 and ?offset=50 or both ?limit=25&offset=50 to page through the results.
This should be easy. Facebook gives a public URL for albums that are public to be viewed by the Internet without necessity of logging in. You can see this URL al the bottom of the album page that you may want to share.
It looks like this:
Share this album with anyone by sending them this public link:
http://www.facebook.com/album.php?aid=[ALBUM_ID]&id=[USER_ID]&l=[SOME_PARAM]
(quoted from a public album)
you can easily leach data and extract images from there.
However it is more sane to create a Facebook app (takes hardy a minute) and use Facebook graph-API to make REST calls to retrieve all the data about albums and photos within them in well formatted JSON that will be far easier to handle the HTML. Once you have Facebook App in place, you may use it to fetch all the FB data but it violates both of your requirements (1)Not using Facebook app, and (2) user don't have to sign-in.
But it may worth looking at
http://developers.facebook.com/docs/api
http://developers.facebook.com/docs/reference/api/album
Well, there is some trick. If you go to the API page(http://developers.facebook.com/docs/api). Copy the URL given for Coca-Cola album (https://graph.facebook.com/99394368305) and make a request with photos REST command like https://graph.facebook.com/99394368305/photos you can access all the details of all the photos in the album in JSON format. I could not get it work for my personal public album though.