FQL - Getting pid of the photos user is tagged in gives different results with different query - facebook

I am trying to get the photos a user is tagged in. I am using the query:
SELECT pid
FROM photo
WHERE pid
IN (SELECT pid FROM photo_tag WHERE subject=me())
The number of results I get is 32. However when I run this query:
SELECT pid FROM photo_tag WHERE subject=me()
The number of results I get is 67. This is the number I expect because I am tagged in 67 pictures, not just 32. What am I doing wrong with the query?

It's possible that you're tagged in photos that are not accessible using the current access_token. Take one of the photo ids from the larger list that you don't see on the smaller list and try accessing it using that access_token.

photo_tag table contains photos in which your are tagged, photo table contains photo uploaded by you
In your situation, you are tagged in 67 photos, and 32 out of 67 photos are uploaded by you, the others are uploaded by someone else (and you're tagged).

I have the same problem. Ownership of the photo does not seem to be the issue. I am able to see some pids (in the outer query) that are owned by my friends.
I run the inner query to get all the pids in which I am a 'subject'. When I try retrieving the details (pid, object_id, subject etc.) for some of these pids , I get an empty string. I don't think it is a permission issue. I have both "user_photos" and "friend_photos" enabled and am using the correct access token.
I tried examining what was different about these few stubborn photos. Some common themes:
1)uploaded from a mobile device
2)Shared with a "Custom" list of friends
But I haven't been able to root cause it yet.

Related

Cover photo changes not showing up in stream table query

I am running the following query in FQL, which returns all the objects on my page's timeline, except the posts reflecting a change in cover photo.
SELECT type,permalink,post_id,message,actor_id,targeting,target_id,tagged_ids FROM stream WHERE source_id=xxx AND filter_key="owner" ORDER BY created_time DESC LIMIT 1000
Is this normal behavior or am I doing something wrong? If so, is there a way to get this information as well?

Photo tags query response of max 400 elements

i'm using new Facebook SDK 3.0 but it's not relevant since Graph API Explorer has the same behavior.
The problem is that when i try to fetch some user photo tags, like "me/photos" or the equivalent FQL query, i get a response of max 400 elements, using either graph or fql.
I already tried using LIMIT field (for example the FQL query is "SELECT src, src_big FROM photo WHERE pid IN (SELECT pid FROM photo_tag WHERE subject=me() LIMIT 1000) LIMIT 1000")
but nothing change.
I also tried with SINCE and UNTIL, but i understood that FB returns a table of 400 rows and then shrink it according to your query.
Is maybe another way to bypass this limit or for some unknown reason FB wanted it and it's not a bug?
Thank you

getting latest photos from friends not working

I tried getting the latest photos fo my friends using a method described here:
FQL - Can i get photos of my friends posted this week
At first it seemed to be working fine but then I noticed that some of the photos of my friends weren't being fetched even though they had a higher timestamp (the photos were being sorted by created field from photo FQL table)...
After a bit of debugging I noticed that the problem is in
SELECT aid FROM album WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1=me()
if I pass a short list of my friends' IDs they are being sorted correctly, but when I pass a complete list not all friends are included in the query result...
Any ideas why this isn't working? Are there any limits on how many values can be passed in a "SELECT XXX FROM YYY WHERE ZZZ IN (?)" query?
Thanks in advance for any advice
The limit seems to be about 5000 records returned in any part of an FQL query.
Assuming you have fewer than 5000 friends, you could cut down on the number of albums returned by modifying your query to inspect the modified_major column to only return albums that have had a photo added in the period of interest. You could alternately look at the modified column to return any album modifications.
Also, it looks like aid and pid are on the path to deprecation. New development should use object_id for maximum compatibility.
So to get all albums that have had a photo updated since 2012-10-01, you could use this query:
SELECT object_id FROM album WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1=me()) AND modified_major > 1349049600
In your outter query change aid to album_object_id and pid to object_id

FQL - How to fetch latest photos of all my friends?

I'm trying to fetch latest photos uploaded by all my friends within last 24 hours using Facebook FQL query:
SELECT pid, caption FROM photo WHERE aid IN
( SELECT aid FROM album WHERE owner IN
( SCV list of all my friends Ids )
)
AND created > 1299341284 ORDER BY created DESC
1299341284 is 24hours back from time of writing this article
I get only few results (cca 20), not all photos. It seems like there is a limitation in number of statements in IN. I'm trying with 308 friends ids. If I put only few ids it works. Do you have any idea how to solve this in effective way? Probably using multi query? Any ideas?
Thanks
Use SELECT uid2 FROM friend WHERE uid1=me() instead of the SCV list.

Facebook Comments Count

I am trying to write a Facebook query that will return all comments posted by a user to his friends,
however I can't seem to find the correct schema. Its as if there are no 'indexable' fields to build this.
Any suggestions please?
With thanks,
Wineshtain
The indirect path for stream comments would be something like
select * from comments where fromid = <my_id> and object_id in (
select post_id from stream where sourceid in (
select uid1 from friend where uid2 = <my_id> ) )
for photos, substitute the middle query with
SELECT pid FROM photo WHERE aid IN ( SELECT aid FROM album WHERE owner IN ( ...
Unfortunately the security settings may restrict the querying your friends wall posts and photos.
I don't believe you can accomplish this in a direct manner as you describe. FQL tables are generally only indexed on a limited criteria (for performance reasons I'm sure). In the case of the Comments FQL Table, you can only select comments via a post ID or an xid.
Unfortunately, this means that you have to know the objects that a user has commented on before you can get the comments for it. You would have to have previously selected all the posts, photos, etc. that you wished to get the comments for before you could retrieve them.