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.
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.
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/)
I have found that there is a way to find which of my friends are the users of my facebook app.
$retrobj=$facebook->api(array('method' => 'fql.query', 'query' =>
"SELECT name FROM user WHERE is_app_user = '1' AND uid IN (SELECT uid2
FROM friend WHERE uid1 = '" . $user. "')"));
The above query will show which of my friends uid use my app.
Then i use a while loop to parse through the returned array.
My question is the following...
If i do not have their id's, is there a way to get all the users even if they are not my friends that use my app?
I haven't found a way that is why i am asking if there is actually a way to do that.
Any help appreciated.
Thanks
No. Facebook found that some developers were building apps just to harvest Facebook usernames, and spam them. They removed the ability to return a list of app and page users.
Any FQL query you run must have one of the indexed fields (marked with a star) in your WHERE clause, or the query will fail. That requires a name, username or user_id. Querying the friend, event_member, stream or checkin tables are a few of the valid ways to get a list of other users.
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 want a list of friends of my friends. Is that possible?
Looks like there's no way to do this anymore. I tried this FQL query:
SELECT uid2 FROM friend WHERE uid1 IN
(SELECT uid2 FROM friend WHERE uid1 = <UID>)
And I get an error message that says this:
Can't lookup all friends of . Can only lookup for the logged in user (), or friends of the logged in user with the appropriate permission
Additionally, there's no friends_friends permission or anything similar. Conversely, you can get your friends' likes using the friends_likes permission, so this looks like an intentional omission.
In essence, it looks like you have to have an install from a given user to get that user's friends.