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/)
Related
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.
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.
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
Is there a way to get friends with relationship_status equals Married using Graph API?
I did it using FQL, but some fields aren't equals and I have problems using RestFB with these fields like birthday which have different behaviors using Graph API and FQL.
FQL code do get married friends
SELECT uid, name, relationship_status FROM user WHERE (uid = MY_ID OR uid IN (SELECT uid2 FROM friend WHERE uid1 = MY_ID)) AND relationship_status='Married'
I wanna to do the same with Graph API
Graph API is more clean I think too.
Thanks
You have the exact query to get all married friends.
Just you have to do is call this FQL query using GRAPH API.
See the following blog for more details on how to call an FQL using GRAPH API.
http://developers.facebook.com/blog/post/579/
Also please read my answer to this question to just to fix any possible errors when using 'file_get_contents' in your code (as in the example of the FB blog post)
try this..
https://graph.facebook.com/fql?q=SELECT uid, name, relationship_status FROM user WHERE (uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())) AND relationship_status='Married'.
I've been playing around the Facebook Graph API for a while now.
I'm trying to get the list of friends using https://graph.facebook.com/me/friends.
While it's working fine, the results are ordered by Id. Is there a way to get them ordered by name, or do I have to reorder them manually via my application layer?
Thanks!
I don't think there is a way of ordering Graph API results, but you can order FQL results. Something like:
SELECT name, uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $current_user_id) ORDER BY name