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.
Related
i use app with v2.3 api, and i wanna to search a friend by name.
Fql was deprecated and with graph i don't know how.
$params = array('method' => 'fql.query','query' => "SELECT uid,name,pic_square from user where uid IN(select uid2 FROM friend WHERE uid1=me() AND strpos(lower(name),'".$search."') order by name limit 5");
You can use the Search API in v2.x:
graph.facebook.com/search?q=yourfriendname&type=user
Another way is to use /me/friends and go throug the results to find the friend by name. Keep in mind that you can only get those friends who authorized your App too though.
Sorry, but this method return just irelevant results, not my friend who searched in facebook bar, not enough closer.
Sorry for my eng.
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/)
As we can get feeds of specific user or fan page, I wanted to know that how can I get feeds from specific Hashtag like in twitter by fql or Graph API ?
I am using Facebook SDK 3.5.2
Thanks.
As far as I can tell, searching specific posts by hashtags is currently unavailable.
You can still find posts regarding a #hashtag querying a user's stream for a specific message:
SELECT message
FROM stream
WHERE
(source_id IN (SELECT uid2 FROM friend WHERE uid1 = me()) OR source_id=me() )
AND strpos(lower(message),lower('#hashtag')) >=0
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.
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