Getting friends' facebook check-ins into a place - facebook

I'm trying to find which of my friends have been to Paris before. I'm trying to use the Graph API to do this.
So basically there's the place id (for Paris it's 110774245616525), I can get basic informations using the endpoint https://graph.facebook.com/110774245616525/ to do this. Then, I'm getting an access_token with friends_status and user_status permissions (using the Graph Explorer) and I'm using this access token to get the checkins. So I'm doing a GET https://graph.facebook.com/110774245616525/checkins?access_token=my_access_token call and all I get is this error message :
page_id is not a member of the checkin table
Although, reading the documentation I see the connection with checkins :
Checkins made to this Place Page by the current user, and friends of
the current user.
Is this an error with the Graph API or with the way I do it?
Thanks !

There's a breaking change for checkins in the July release https://developers.facebook.com/roadmap/ it mentions renaming page_id to target_id so this might be what's causing it. However the following fql query might be a starting point for you
select author_uid from checkin where target_id = 110774245616525
author_uid should be the person who checked in https://developers.facebook.com/docs/reference/fql/checkin

I got the following fql to work to display all the names of my friends who have checked in at a specific location. Only tried it in Graph API Explorer, and it was fairly slow :/ Let me know if it's helpful :)
Select name from user where uid in (Select author_uid from checkin where author_uid in (select uid2 from friend where uid1=me()) and target_id=110774245616525)
An additional note: I noticed that many of my friends show up in the "Friends who have visited Paris, France" box, but they don't have any actual checkins there. I think that the box also checks to see if your friends have any photos from paris.. Just a thought

With the help of asifrc and TommyBs I found a way to do this in FQL using this query :
SELECT name
FROM user
WHERE uid IN (
SELECT author_uid
FROM location_post
WHERE distance(latitude, longitude, "48.856614", "2.3522219") < 5000
AND author_uid IN (SELECT uid2 FROM friend WHERE uid1=me()))
It's pretty much getting all my friends, searching all their posts close to the center of Paris, then getting their names.
If anyone knows how to do this in Graph API, please let me know, because it's still not a good idea to rely on FQL, I think.

Related

Facebook Graph API - Finding friends who like a page

I'd like to create a call to the Facebook Graph API to find friends who like a specific page.
In FQL it would be something like this:
SELECT uid FROM page_fan WHERE page_id=MYPAGEID AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
But this doesn't work as FQL is deprecated.
I can't seem to find a way to do this on the new version of the API.
Any suggestions? Iterating all fans of a page and compare them with the array of is not the best idea I guess? :-)
Thanks,
Koen
Facebook have locked down a lot of options for privacy, but the closest remaining endpoint might be Social Context
So, a call to graph.facebook.com/v2.4/{page_id}/?fields=context should show have a friends_who_like node, which would show you what you're looking for.

Facebook graph api search friends

Is there any way using the graph api to search all users but to list matching friends first?
If I search using this it requires a user access_token. So it knows who I am. So why does it (almost seem like its) avoiding displaying my friends? Why doesn't it return my friends that match the query first and then after that, anyone else?
Is there a way to make it mimic that functionality?
I also wondered the same thing as the OP. The only thing I've been able to come up with in my research is using FQL...The problem with FQL? After v 2.0 of the Facebook API it will no longer be available--and the version after that it will probably be deprecated.
But in the interest of getting a working solution NOW, I found this SO (third answer down): searching friends using facebook graph api
Here's the example that worked for me:
select uid, name, sex
from user
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'Jack')>=0 OR strpos(name,'Jack')>=0)
Also, if you want their pic use:
select uid, name, sex, pic_small
from user
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'Jack')>=0 OR strpos(name,'Jack')>=0)
(I'm getting their small pic but documentation for other sizes of the pic is found here: https://developers.facebook.com/docs/reference/fql/user/)

Get facebook check ins via FQL or Graph api

So what I need to achieve is to get all facebook check ins for certain user (myself, or my friend).
According to FB documentation over FQL that should be simple, for example:
SELECT author_uid, tagged_uids, target_id, timestamp FROM checkin WHERE author_uid = me()
But atm I'm not getting any errors, only empty data array in return, but obviously I have a lot of facebook check-ins also, if I tried with different author_uid's (friends of mine, all permissions are granted) I'm getting the same response.
For me this is not logical and if I'm doing something wrong here I would realy appreciate if u can point me in right direction ;)

Can I get all my friends checked into a particular page/place given that I know the page_id?

SELECT author_uid FROM checkin WHERE page_id IN ('314124218488')
When I do that I get an empty [].
but if I do
SELECT checkin_id, author_uid, page_id FROM checkin
WHERE page_id IN ('314124218488') AND author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
I do get one of my friend however this is really really slow!! since if i have about 500 or more checkins from my friends, it is going to check all my friends against the check-in object!
why cant i get people/friends checked into the page by just doing:
SELECT author_uid FROM checkin WHERE page_id IN ('314124218488')
I had the same problem and I managed to fix it.
When using the checkin query, make sure all the permissions are correct, try using the api explorer. http://developers.facebook.com/tools/explorer/?method=GET, i found that checking the permission:friends_notes i could get all the info i needed. Make sure you also check relevant permissions like: friends_location etc when getting an access token(you get a temporary one using the explorer)
Try the API query <PAGEID>/checkins?fields=from,message in the explorer
No user ID is needed and you get all the friends that checked in to the page with the pageid <PAGEID>.

How to get Mutual Friends via Facebook's Graph API

Is there anyway to get a list of mutual friends using Facebook's Graph API?
I've been playing around with this tool and haven't yet figured out a way. However, I saw Simon's demo on Facebook's site, and it sounded like he was able to get the mutual likes of friend of his (it was too blurry to see how he did it so) so I feel like I ought to be able to, but I can't find any documentation besides some php scripts.
The Mutual Friends API was deprecated on April 4, 2018, and the endpoints below started returning empty data sets. The endpoints are now fully deprecated and will return an error. https://developers.facebook.com/docs/graph-api/changelog/version3.1#mutual-friends-api
You can use this one to get mutuals friends from the graph
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmutualfriends%2F1207059
Goto the API Documentation page here:
http://developers.facebook.com/docs/reference/api/
Mid-way down the page you will see:
•Friends: https://graph.facebook.com/me/friends?access_token=...
You'll need to replace the /me/ with a valid ID of the person you are looking for and you;ll need to get the access_token as well.
Hope this starts you in the right direction..
EDIT: There is also this which may be easier:
http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends/
Legacy REST method
I would do this as a FQL query and test it with their FQL tester. This might not be 100% what you are looking for, but it should be enough to get you started:
SELECT uid1, uid2 FROM friend
WHERE uid1 IN
(SELECT uid2 FROM friend WHERE uid1=me())
AND uid2 IN
(SELECT uid2 FROM friend WHERE uid1=me())
You could then look up these id's up against the user table.