What is the difference between a Facebook Page "Like" and an external URL "Like"? And will the "user_likes" permission scope give access to both? - facebook

I'd like to pull a list of all Facebook "Likes" for a user, whether they are Facebook pages or external URLs.
Example:
If you "Like" the Facebook Platform, I know I can see it via the /me/likes API call.
However, if you like an external URL, I'm not sure how to pull that. Are both supposed to be pulled via the /me/likes call? Or is there another call to handle external likes?
Further, what about newsfeed / stream likes? For example, if I "Like" a photo, video, status or link that I see in my stream, is that accessible via the API? If so, how is this accessed?

Yes, user_likes will give you access to both.
You can access external likes as you wish through the Graph API endpoint /me/likes, as long as they're not articles. Objects with type "article" do not represent real-world objects and as such, we don't provide on a person's profile. We mention this (albeit obscurely) on the Open Graph documentation page: https://developers.facebook.com/docs/opengraph/#types
So if you go to my fake movie object page at
http://fbsb.hoodlu.ms/so_7436857/video2.html
and click like, that will show up when you access your likes on https://graph.facebook.com/me/likes.
Try it using the Graph API explorer:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Flikes
If you want the URLs that someone has liked, use this FQL query:
SELECT url FROM url_like WHERE user_id = me()
More information is available at https://developers.facebook.com/docs/reference/fql/url_like/.
If you want to access the likes from a post, photo, video, etc. you'll need to use the like and stream FQL tables. To just pull out the likes (of posts/photos/videos) for the current user:
SELECT user_id, object_id, post_id FROM like WHERE user_id=me()
From there, you would query the stream table for the post to get more information.
like table documentation: https://developers.facebook.com/docs/reference/fql/like/.
stream table documentation: https://developers.facebook.com/docs/reference/fql/stream/

Facebook now has two ways to read likes. If you would like to get the likes of an external URL you try this:
http://graph.facebook.com/me/og.likes/[ID_FACEBOOKOBJECT]
And if you wish get the likes from an internal Facebook page (fan page,profile,photo like) try this:
http://graph.facebook.com/me/likes/[ID_FACEBOOKOBJECT]
Checkout: https://developers.facebook.com/tools/explorer

Related

facebook likes that WE have done

We have several people working on our Facebook page, and I am trying to find out if there is a way to list all the companies that WE have liked - not the ones that like us.
I know that isn't possible to do (apart from analytic data). We are a chamber of commerce, and we were liking all our members who are on Facebook, hoping to be able to look back and find out how many are actually on Facebook.
Hope this makes sense, and I hope it is possible. :)
Sure just go to: https://developers.facebook.com/tools/explorer (you must be a registered facebook developer to acces this tool).
Then on the input where you have this:
your_fb_id?fields=id,name
change it to this
your_fb_id?fields=id,name,accounts and press send.
You'll get all the pages wich you're administrator, choose the one you want by clicking on the respective ID. Now you're querying the page you've chosen. Last step, on the input to make queries change it to this:
your_page_id?fields=likes
EDIT
The previous request only returned the number of total likes made by the page.
To get the likes made by the page on other pages you have to use FQL Query
Change from Graph API to FQL Query and paste this
SELECT page_id, name FROM page WHERE page_id IN (SELECT page_id FROM page_fan WHERE uid = your_PAGE_ID)
This is without doing any code, if you want to get the information and format it on your own way, you'll have to develop an app where you grant the permission manage_pages and user_likes(this one I don't think is mandatory though), use the graph api to get the likes and format the json returned data

How do I generate Facebook like button with only the FB page ID

So I have a database table with the Facebook page ID's of my users. I would like to generate a like button dynamically with only the ID available to me to do this. The problem as I see it is that I don't know what the data-href attribute is supposed to have considering that Facebook page url's look like this: http://facebook.com/pages/hyphenated-name/<?=$FB_id?> and I don't have the hyphenated name stored in my database to generate the that url.
Is there another URL structure Facebook's back-end will accept that just has the ID and not the hyphenated name, but will still count likes on that person's Facebook fan page? Is this impossible?
You can do a look up of the id, and retrieve the link of the page stored.
example: https://developers.facebook.com/tools/explorer?method=GET&path=191825050853209
refer to: https://developers.facebook.com/docs/reference/api/page/ under link connection.
This method will require use of the graph api, or one of the sdks.
refer to: https://developers.facebook.com/docs/reference/api

Facebook Graph API: How do I get a user's (or own) link-likes (i.e. 'user likes a link')?

By link-like I mean a generic page on the Web (link) that a user likes using a Facebook button (i.e. NOT a Facebook standard page).
The Graph API method /user/feed does not return link-likes.
The Graph API method /user/likes only returns Facebook page likes, but not link-likes.
Do you know of any ways that I could get to link-likes?
When you get this kind of entry you get and id something like:
"id": "1392236262_349397875123264"
The first part of id is user id, the second is the liked link id. You can get an information about it by running other Facebook Graph API call:
https://graph.facebook.com/349397875123264
This way you will get all information about this link.
You can get list of liked urls using fql:
SELECT url FROM url_like WHERE user_id = me()
http://developers.facebook.com/docs/reference/fql/url_like/

Get Facebook Link Likes

Using the Facebook API with the FQL language, how can I get a list of the users that liked a given URL? I got the URL and want to query Facebook to see how many people and what users liked that URL.
Using PHP or ASP.Net... doesn't matter, just want to know how to write the FQL query.
Sadly this data isn't available. What's possible via the Link Graph API objects and the link FQL table is just retrieving a given instance in which a link was shared by a user. You can get the count of likes on a user's posting of a link, but this likely isn't what you want.
Discussed this 3-6 months ago with guys at Facebook, and the consensus then was also that getting this data via API is impossible. As far as I know things haven't changed, and there are some privacy arguments for keeping this data out of the API.
'SELECT user_id FROM like WHERE object_id IN (SELECT link_id from link WHERE url = 'YOUR URL HERE' AND owner = 'YOUR USER ID HERE' '
Like FQL Table
Link FQL table
In order to access user's likes, the application needs to have user_likes permission from the user. After that if you access http://graph.facebook.com/me/likes with appropriate access tokens, all the object IDs (including external websites), the current user has liked will be listed.
(this is in reply to bounty question, which seems a bit different from the original question asked on this page)
It's not using FQL but...you can see the most recent 500 users that have like your page by going to: https://www.facebook.com/browse/?type=page_fans&page_id={id} but you would have to scrape this to get the information and it won't work for more people besides the most recent 500. Here's the gotcha, you've gotta be an admin of the page_id to see it.
You can only get the fans of pages that you are an administrator for. So you have to provide an access token with your request associated with an admin account of the page you are trying to get the fans.
Facebook's FQL documentation here: https://developers.facebook.com/docs/reference/fql/page/ tells you how to do it. Run the example SELECT name, fan_count FROM page WHERE page_id = 19292868552 and replace the page_id number with your page's id number and it will return the page name and the fan count.

What is the API for Facebook 'profile stream' aka wall posts?

Is there an API call, and if so, which call to get the 'posts to my wall from myself and others' on Facebook? It seems like it could be filtered out of the Facebook stream API, but it's not clear how that works to me.
This link seems to imply it's possible:
http://developers.facebook.com/news.php?blog=1&story=225
You want to do an FQL query like this:
SELECT actor_id, message FROM stream WHERE source_id = <user id> limit 50
You will probably want to select a few more fields, you can see what is available here: http://wiki.developers.facebook.com/index.php/Stream_%28FQL%29
Here it is.
Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=...
https://developers.facebook.com/blog/post/465
You can publish stories to people who like your Open Graph Page the same way you write a Facebook post from your own wall. The stories appear in the News Feeds of people who have clicked the Like button on the Open Graph Page.
You can also publish using our API. If you associate your Open Graph Page with a Facebook app using the fb:app_id meta tag, you can publish updates to the users who have liked your pages via the Graph API.
First you need to get an access token for your app.
Check out the blog post, it covers everything you need.