I need to know if that's possible using the Facebook API?
Get everyone that liked my page (Less than 50 people)
Get all the pages they liked
Query to see if any of the people that liked my page liked my competitor page as well?
thanks,
Answer:
No way. Reference: graph api - retrieve list of likes of a page
Request https://graph.facebook.com/{user-id}/likes endpoint. Documentation: https://developers.facebook.com/docs/graph-api/reference/user/likes/
Request https://graph.facebook.com/{user-id}/likes/{page-id} endpoint. Documentation: https://developers.facebook.com/docs/graph-api/reference/user/likes/
3.1 Request FQL to check multiple userid in only one API call, for example, if one of the user id from the list (e.g. 4,5,12345,777) have liked the page, it would return the relevant user id, i.e. 12345 as shown in this screenshot.
SELECT uid FROM page_fan WHERE page_id = 279183048899677 AND uid In (4,5,12345,777)
Documentation: https://developers.facebook.com/docs/reference/fql/page_fan/
Facebook dismiss FQL after 8 Augsut 2016 Now you need to use only Graph API.
Related
I am trying to get user's like from a given link-
for example my link would be- "http//:www.example.org"
Now trying to get whether user has liked this link before or not.
FB.api({
method: 'fql.query',
query: "SELECT uid from object_id WHERE uid = " + user_id + "and link_id =" + page_url
}, function (rows) {
console.log(rows);
});
But this query doesn't shows undefined in console.
I want to know the way of doing this using facebook graph API reference.
Afaik you can only get Likes of Facebook Pages via the Facebook API, but not Likes of external websites. Also, keep in mind that FQL is deprecated and only available in v2.0 of the Facebook API. Which means, it will get removed when support for v2.0 runs out (2-3 years probably).
Getting the Facebook Page Likes is pretty easy though: /me/likes ... Although, you need to let Facebook review the permission in v2.0.
Upgrade guide (v1.0 > v2.0): https://developers.facebook.com/docs/apps/upgrading/
There is one way to check if a user liked something on an external website, but only right when he clicks on the Like Button: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.0
Edit: After some testing, i figured out that it is indeed possible to get the Likes. Although, i think there is a bug in FQL - You can get a list of external Likes with the following FQL query:
SELECT url, user_id FROM url_like WHERE user_id = me()
...but if you add the url to the query, the result is emtpy:
SELECT url, user_id FROM url_like WHERE user_id = me() AND url = '...'
There is a similar question on stackoverflow btw, maybe you want to take a look at the answers: Retrieve Facebook users that like a URL / web page via Open Graph
How can we get a list of facebook ids of all the people that like our page?
Can we write some kind of code that goes over the page and gets them?
You can't get a list of ALL the users who have liked a particular page using the Graph API or FQL.
However, you can get a count of number of users who have liked your page by using:
SELECT fan_count from page where page_id = {page_id}
And you can also check whether any of the user in your friend list has liked a particular page or not (this requires additional friends_likes permission). This can be done by using:
SELECT created_time from page_fan where
page_id = {page_id} AND uid IN (uid1, uid2, ...)
EDIT: Just found out there's already a discussion going on regarding this on Stack Overflow. Take a look at this question: Facebook API: Get fans of / people who like a page
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
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/
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.