Show friends on application - facebook

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

Related

FQL is_app_user is not working anymore

I have a few Facebook apps, and I use the following FQL to get the list of app users:
SELECT uid,name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1
and it works fine, but now I created a new app, and the above FQL always returns empty and I know for a fact that I have friends using the APP,
Any ideas?
The problem was solved by adding "user_friends" to the list of requested permissions, I didn't need this permission in Graph API V1.0

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

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

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)

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.

Getting friends using the same application on Facebook

I'm using play framework to create a facebook application. I'm kinda stucked at some point. With Graph Api i can't take a list of friends who use my application. What i want to say is for example:
A is using my application.
B is using my application too and B is a friend of A.
When A is using my application, I want A to see B is also using this application.
Simply I want to get list of friends using same application.
How would i do that with Graph Api?
There is a field called "is_app_user" on the user table that you could run a FQL query against. The query would be something like:
select uid, name
from user
where is_app_user = 1
and uid in (SELECT uid2 FROM friend WHERE uid1 = me())
The graph url for that would be like this (remember to add an access token):
https://api.facebook.com/method/fql.query?query=select uid, name from user where is_app_user = 1 and uid in (SELECT uid2 FROM friend WHERE uid1 = me())&access_token=...
With Friend A's access token do a Post to me/friends to get the list of friends. See if Friend B is on the list. See: http://developers.facebook.com/docs/reference/api/user/