I'm trying to grab the Facebook pages that my friends liked.
SELECT uid,page_id,type,profile_section,created_time FROM page_fan WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
I noticed that some data is missing from the result set, therefore I queried the table for individual user ids, as follows:
SELECT uid,page_id,type,profile_section,created_time FROM page_fan WHERE uid={id1}
SELECT uid,page_id,type,profile_section,created_time FROM page_fan WHERE uid={id2}
...
Apparently for some friend ids is working, but for some others the query returns empty result.
I thought that maybe those missing users have some privacy settings not allowing apps to pull data from their accouns.
Any thoughts?
Are you using a valid access token when making this request?
If you look at the documentation for the page_fan table it explains what access tokens are needed
https://developers.facebook.com/docs/reference/fql/page_fan/
To read the page_fan table you need:
any valid access_token if it is public (visible to anyone on
Facebook).
user_likes permissions if querying the current user.
friends_likes permissions if querying a user's friend.
Related
I have a problem. I am using fql to get user information. I want to take the pages the user has liked.
https://developers.facebook.com/docs/reference/fql
I have been investigating all tables, but I have not seen what I wanted.
If you know how can I do it, that would be fantastic.
Thank you!!
You want the page_fan table
https://developers.facebook.com/docs/reference/fql/page_fan
uid should be an indexable field
here's a sample FQL query to get you started
select page_id,name from page where page_id in (select page_id from page_fan where uid=me())
https://developers.facebook.com/tools/explorer?fql=select%20page_id%2Cname%20from%20page%20where%20page_id%20in%20(select%20page_id%20from%20page_fan%20where%20uid%3Dme())
I need to find out who all(my friends only) are tagged in a specific photo. I know the pid of the photo. This needs to be done via a FQL query.
Any help?
Here you go. This will give you most of the data you should need about a friend tagged in a specific photo.
SELECT id, name, pic_square, username, type FROM profile WHERE id IN
(SELECT subject FROM photo_tag WHERE pid = XXXXX AND subject IN
(SELECT uid2 FROM friend WHERE uid1 = me() ) )
You may not get all your friends with this query who are visible in the Facebook app. This depends on how they have their privacy settings configured. The API won't return their data to you if their privacy isn't set to public.
Depending on how you're getting it, you may want to sub out object_id for pid. The pid field seems like it's on the path to deprecation.
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.
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.
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