How to use facebook api to show friends been to a place? - facebook

I am building a website with venues (for exaple cinemas) and i need to show to the user (user logged in with facebook) his/her friends that have checked in to this place.
I am using long, lat for my places. I am thinking of using a query that will bring the check ins from user;s friends, that are specified by a location center and a distance:
https://graph.facebook.com/search?type=location&center=38.01166,23.69272&distance=30&access_token=AAAAAAITEghMBAOL5MyxLDoFpRlirSFmEYYGZB7tHd8BH8YsUOW03uX4ewz6lVVPFWudujS0RZC7HdXm2r7OfVvnEgSr3KqRw4Q5WqlEeCNYm07XxyO
Is the query right? Is there any better way? How am i going to show to the venue page on my website, the users' profile pics?
What i realy need to create is something like this!(from tripbirds.com)
but i only want to show their photo not their post on that place.
http://imageshack.us/photo/my-images/13/22811412.png/

Since each place has its own page_id, you can use the checkin table and friend table to construct a query like -
select author_uid from checkin where page_id = [PLACEID_WHERE_CHECKEDIN] and author_uid in (select uid2 from friend where uid1 = me())
And once you have the friends' id, it's simple to get their info and profile pic from the user table. If you really wanted to do it in 1 query, you could enclose the above in a query like -
select pic_square from user where uid in (ABOVE-QUERY)

Related

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/)

FQL to Find who all(uid) of MY FRIENDS are tagged in a photo with pid=N?

I need to find out who all(my friends only) are tagged in a specific photo. I know the pid of the photo. This needs to be done via a FQL query.
Any help?
Here you go. This will give you most of the data you should need about a friend tagged in a specific photo.
SELECT id, name, pic_square, username, type FROM profile WHERE id IN
(SELECT subject FROM photo_tag WHERE pid = XXXXX AND subject IN
(SELECT uid2 FROM friend WHERE uid1 = me() ) )
You may not get all your friends with this query who are visible in the Facebook app. This depends on how they have their privacy settings configured. The API won't return their data to you if their privacy isn't set to public.
Depending on how you're getting it, you may want to sub out object_id for pid. The pid field seems like it's on the path to deprecation.

How to get only friends with profile photos uploaded, and ignore those users with the default silhouette?

I cannot figure a way get friends only with profile photos. I could use multi-query to check whether every friend has a photo, but that would incur heavy traffic.
Are there any alternatives?
Although Gajus’ suggested query might work right now, it’ll break once Facebook changes the URL of the default picture on their CDN. (Might happen, might not happen.)
So I’d suggest this for improvement:
The profile_pic table has a field called is_silhouette, which is a boolean for whether the user has their own profile picture set or not.
So to get only those of your friends, that have a profile picture set, you can use
SELECT uid, name FROM user WHERE uid IN
(SELECT id FROM profile_pic WHERE
id IN (SELECT uid1 FROM friend WHERE uid2 = me() )
AND NOT is_silhouette
)
–> Try this query in the Graph API Explorer.
This can be achieved with a simple FQL.
SELECT uid, name, pic_small FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND pic_small != 'https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yP/r/FdhqUFlRalU.jpg'
The seb-query will get all yours friend uids. The other query will match does uids with the profile data check if the pic_small is referring to what Facebook uses as a placeholder.
You can quickly test it here.

Show friends on application

I have a FB app. I need to have a functionality similar to which is present on Washington post reader that shows friends on the app.
Is it FB facepile? If so, then how have they implemented to show more than 4 friends with a button? Have they implemented it server side ?
You can use FQL to retrieve friends using the same app.
Simply use the query below and you should be able to get frineds' uid, name and is_app_user.
*is_app_user* indicates if a given user is using your app or not.
select uid, name, is_app_user from user where uid in (select uid2 from
friend where uid1=me()) and is_app_user=1

facebook fql query to retrieve friends posted items

Is there any fql statements allowed by facebook that helps to fetch contents of this page through an application interface: http://www.facebook.com/posted.php I know the links table returns the posted item for a logged in user (http://developers.facebook.com/docs/reference/fql/links). I need the same but for the logged-in user's friends.
Thanks.
you can use Fql query or Graph API to get your friends data.
Sometimes you will not get all information from the graph like birthdate of your friends but yes you can use fql queries to solve your probs.
here is an exmple for you.
create first facbook object and the use it.
$query = "SELECT uid, first_name, last_name, birthday_date, sex, pic_square, current_location, hometown_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 0 ORDER BY birthday_date";
Regards,
Archit.
You can do this through an FQL query - though you may need to use multiple queries if you require more information about the friend who posted the link:
select title, owner from link where owner in (select uid2 from friend where uid1 = me() limit 100)
You may want to limit the number of friends (or even the links themselves) as this can be a costly query