Facebook API: how to find if a user liked my page - facebook

I need to check, using facebook graph api, if a facebook user has liked a certain page (I am the admin and can grant myself any permission). Does anyone know how I can achieve that?
I can't find it in the docs. The closest in the docs is the following:
https://developers.facebook.com/docs/graph-api/reference/v2.10/object/likes/
It says that the request returns: "An array of User or Page objects representing the people or Pages that liked the object" Which is in fact what I am looking for, as I could simply query the user in the list and see if there is a match. BUT , in fact, what the request (mentioned above) actually returns is an array of User or Page objects representing the people or Pages that the object (my page) liked.
The request from the docs might sill be implemented to solve the problem:
facebook graph api if a user has liked a page
BUT it doesn't help me, because I don't want to take the user's permission. I want to implement the solution from the side of the admin of the page- the admin needs to check for multiple users if they liked the page or not.
Can anyone help me sort this out?

Related

fb graph api multiple userid and page like

from my ios app after fb login, facebook returns me the userid.
i call https://graph.facebook.com/v2.8/me/likes/[pageid]?access_token=...
to check if the user likes my fb page. But i get empty array while the same user has liked my page from the web.
The user has different userId when logins directly to facebook website and different when logins in my app. While the user has liked my page from web , how can i see it in the api call from my app using the userid that fb returns me when he logins from my app?
Thank you very much
Please note that there is no direct way of checking whether a particular user has liked a certain page or not using FB Graph API.
But i believe there is a workaround for this and you can try to hit the below URL in your browser
https://www.facebook.com/search/<page_id>/likers?ref=about
It will return all the people information who have liked the page provided. I am not sure would this return all the results or just some of them. But i believe you can try this.
You can then do some web scraping which will help you indentify whether 'person A' has liked a page say 'abc'.
Now you can hit the below endpoint to retreive all the likes this 'person a' has liked
FB.api('/person_id_obtained_from_above/likes')
But please note that you need user_likes permission to retrieve someone else's likes
Let me know if this worked for you.

How can I recommend one kind of content to a user, based on their liked pages from Facebook?

I'm trying to create a small recommendation system based on what pages people like in Facebook. This is how it will work:
someone will login with Facebook
accept the terms to retrieve information
then the program should get all pages this user liked
Concern
Since I have all the liked pages from a user, which page should be the most relevant for recommendation?
I was trying the Graph API Explorer from Facebook to get all my likes or even comments made to posts of a page that I liked, so with that I could count and prioritise the pages in my program.
However I thought this should be a security issue and after testing I confirmed that was not working (user access tokens permissions were selected correctly for this test).
Questions
Is there a way to make this work?
Should I use another solution?

Facebook : List of all pages liked by

I am new to Facebook's Graph API and FQL. I want small information about the same.
I want to get List of all pages liked by any particular user.
I have used Graph API just to allow user to get logged in with their Facebook ID and Can access their wall but don't know much about rest of the this.
I searched on Google for same but got information about list of pages that user administrate that I don't want, I want full list which is like by them.
It's a connection property of the User object.
https://developers.facebook.com/docs/reference/api/user/#likes

Does /me/likes/page_id require user_likes permission?

Previously, Facebook app's could check if a user liked a given page (for fan-gating) by calling the following Graph API method with no special permissions other than basic authentication:
/me/likes/page_id
This would return a data property with the page's details if the user has liked it previously, or an empty array when the user hasn't liked the page.
Seems that this has recently stopped working. Instead, the only way to get this information is, if the user_likes permission had been granted prior.
The same problem is encountered when using
/page_id/members/user_id
Is there any information on what's causing this new behaviour?
I'm guessing here, but the 2nd call you list would imply that the current user had rights to veiw your page's members list. Really the list of people who like a page should be restricted to the page owner although Facebook does show you who of your friends likes the page as well.
As for user liking the page, I've been searching today for the same and this answer seemed to be the best so far:
StackOverflow: Check if user likes page via Graph API

Get all posts on a friend's wall

I'm trying to find an API call (or set of calls) that will allow an app to get the posts that one would see if viewing a friend's wall. Either a REST call or a FQL call would do.
I tried /feed and /posts, compare the results with what I see on my friend's wall, and the results I get from it are incomplete.
I know this is possible because apps like Friendly are able to do it.
Any hints?
Well, there's two different API endpoints for querying the posts of a given user; home and feed. Home includes posts from other people and pages (basically what you see when you log in and go to your home page) and feed is the stuff the user is sharing. Assuming your application has authenticated the user and they've allowed the read_stream permission, you can then make queries to the Graph API using their access token:
https://graph.facebook.com/{SOME_USER_NAME}/home?access_token={SOME_ACCESS_TOKEN}
and
https://graph.facebook.com/{SOME_USER_NAME}/feed?access_token={SOME_ACCESS_TOKEN}
The only hint I could give you is that "incomplete" is pretty standard with the Facebook API. You can only do the best you can with what they give you. Counts will be wrong. Data will be wrong. It's a fluctuating, moving target, so code to that fact.
You can interact with posts by retrieving the read_stream and publish_stream for a given User's ID.
Once you have the ID of the User that you are interested in you can use FQL to retrieve posts from streams that you have the permissions for.
This stackoverflow answer goes into more detail and contains further links to the documentation on the Facebook Developers site.
We do it like this:
1) we use Facebook Platform PHP5 client
2) then what you do is:
$this->facebook = new facebook($key, $secret);
$out = $this->facebook->api_client->call_method("facebook.stream.get", array('viewer_id'=>0, 'source_ids'=>$uid, 'limit'=>$limit));
then just operate with out, which contains all posts on asked page.
but, afaik, it will work only with pages, not with normal users. but dig that way to get answer.
You should make a graph call to https://graph.facebook.com/< FBID >/statuses?access_token=xxxxx
Here access_token shall have read_stream permission and offline_access permission ..