Retrieve user's friends who like the same fan page - facebook

I try to find facebook api to retrieve user's friends who like the same fan page but I dont think the new graph api able to do this.
While searching in the stackoverflow, I came out with this FQL:
select user_id from like where object_id = "[page_id]" and user_id in (select uid2 from friend where uid1 = me())
but facebook return me with
array(0) {
}
is there any solution ?

You can do this with FQL:
SELECT uid FROM page_fan
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
AND page_id = "[fan_page_id]"
Which returns you friends who are fans of given fan page ([fan_page_id]). It works at this moment quite well.

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

How to get all liked movie pages of a user

Is it possible to get all liked movie pages via FQL?
The most stable way currently to get the names of the pages not necessarily the ids would be to run a query on the user table. page_fan returns little to no results even though the user may have numerous pages likes of type Movie.
SELECT movies from user where uid=me() and movies != ''
or for all friends
SELECT movies from user where uid in (SELECT uid2 FROM friend WHERE uid1 = me()) and movies != ''
There is currently no way to get all like movie pages of a user (in terms of ids) via FQL.
Update: I jumped the gun.
This should work
SELECT name, page_id from page where page_id in (SELECT page_id from page_fan where uid in (SELECT uid2 FROM friend WHERE uid1 = me()) and profile_section='movies')
Though it's still unstable and doesn't return all matches >.<
Yes it is. Check out the Graph API Explorer. You can run FQL statements on the page_fan table from there. You'll need to require the user_likes permission and then parse out the movie entries. that field is not index.
yes, just query the FQL page_fan table http://developers.facebook.com/docs/reference/fql/page_fan/ with the correct permissions.

searching friends using facebook graph api

Does facebook have an api for searching a user's friend?
Tim
You can search friend's name like this:
select uid, name, sex
from user
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'TheFriendName')>=0 OR strpos(name,'TheFriendName')>=0)
TheFriendName=Full name or part of the name
Example:
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)
You can get the list of friends using the following API call:
Friends: https://graph.facebook.com/me/friends?access_token=...
and then search in the list for the person you are looking for.
Refer to more detailed documentation here: http://developers.facebook.com/docs/api

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

FQL facebook query language: how can i query the list of friends of a specific user that has my application installed?

When a user logs in to my facebook application, i want to show him a list of all of his friends that has my application installed.
can I use FQL to query who's of his friends have my application installed? and if so how ?
thanks!
Actually, you can do pull list of friends who installed an app through FQL.
SELECT uid, name, pic_square FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
You can do it like this also, if is_app_user=1 then its app user.
NSString *query =
#"SELECT uid, name, pic_square,is_app_user FROM user WHERE uid IN "
#"(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)";