In facebook FQL filter by created_time on video table doesn't work as expected (i.e. return old results) - facebook-fql

I have the following query on the video table, and it return old results.
SELECT owner, vid FROM video WHERE owner = 123456 AND created_time > 1347789391
ORDER BY created_time DESC LIMIT 100
Similar query on photos perform the filter as expected
SELECT owner, caption, FROM photo WHERE aid = 123456 AND created > 1347789391
ORDER BY created DESC LIMIT 100
Any ideas?
I looked for known bugs but couldn't find any. My workaround is to check the return results and do the filter my self, but that of course not ideal.

Related

Incorrect/incomplete results from FQL

So, I need to get the most recent photos from my friends. I tried running some queries from my code as well as from the FQL explorer at http://developers.facebook.com/tools/explorer
The following query never returns.
SELECT src_big, created, owner FROM photo WHERE owner in (select uid2 from friend where uid1=me()) order by created desc
Perhaps not a good idea to use the WHERE clause on owner, even though the FQL docs do say owner is indexed. So, I modified it to:
SELECT src_big, created, owner FROM photo WHERE aid in (select aid from album where owner in (select uid2 from friend where uid1=me())) order by created desc limit 2000
and that does return but only returns photos from 3 of my friends and the total photo count is nowhere close to 2000.
I tried restricting the results to only photos created in the last 7 days.
SELECT src_big, created, owner FROM photo WHERE aid in (select aid from album where owner in (select uid2 from friend where uid1=me())) and created > 1361570941 order by created desc limit 2000
Now I get only 1 photo (obviously from 1 owner).
Then I tried the last 365 days.
SELECT src_big, created, owner FROM photo WHERE aid in (select aid from album where owner in (select uid2 from friend where uid1=me())) and created > 1330639808 order by created desc limit 2000
Now I got more photos, but still not 2000, and again only from those 3 owners.
If I now loop through each of my friends and run this query:
SELECT src_big, created, owner FROM photo WHERE owner = and created > 1330639808 order by created desc limit 100
then I get proper results, and eventually when I am done with all friends I have photos from 202 friends, and if I sort the overall result by created, those aforementioned 3 owners don't dominate the top rows. There are many owners who have posted photos in the top 2000 spots, so the previous queries are clearly returning incorrect (incomplete) data.
But the last way to do it (loop through all friends) is terrible for performance compared to the previous queries - we are talking several minutes instead of a few seconds.
Is this a known problem or limitation? Any workarounds?
A Facebook employee friend of mine suggested using multi-queries as in:
{
"p1" : "SELECT src_big, created, owner FROM photo WHERE owner = 4850 AND created > 1341203410",
"p2" : "SELECT src_big, created, owner FROM photo WHERE owner = 5569 AND created > 1341203410"
}
I haven't tried it out yet, but I am guessing it will be much faster than making an API call per friend.
He said he will file a bug on the incorrect results from my original query.

Get friends most liked photos from facebook using fql

I am trying to obtain most liked photos of my friends in 2012. I have made the following query.
SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified, like_info
FROM photo WHERE created > 1325356200 and aid
IN (SELECT aid FROM album WHERE owner
IN (SELECT uid2 FROM friend WHERE uid1=me()))
ORDER BY like_info.like_count DESC LIMIT 30
It is giving me most liked 30 photos in descending order. But when I inspected the photos I could understand that the list is not correct. Some most liked photos of my friends's is not there in list. I inspected the query many times. I couldn't understand what is wrong with this query. Can anyone help me to find out why this query is not giving the desired result?
Any suggestions are most welcomed.
The problem is due to the default LIMIT value of every FQL query (LIMIT 100).
Firstly SELECT uid2 FROM friend WHERE uid1=me() query runs and outputs your 100 friends
Secondly SELECT aid FROM album WHERE owner IN (..100 Friends...) query runs and output s100 albums of ur 100 friends.
Finally SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified, like_info
FROM photo WHERE created > 1325356200 and aid IN (...100 Aid...) ORDER BY like_info.like_count DESC LIMIT 30 query runs and outputs the result from 100 albums.
Apparently the result is not at all what u wanted. You might try to increase your limit by yourself (say LIMIT 1000) but it never worked for me. The only way of getting accurate result is trying graph API, but it will take very long time for executing, eventually its a dead choice.
The Proof for my answer
Try to run these codes
SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified, like_info
FROM photo WHERE created > 1325356200 and aid IN (SELECT aid FROM album WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1=me() order by rand() ))ORDER BY like_info DESC LIMIT 30
I used rand() function to randomize the friends
SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified, like_info FROM
photo WHERE created > 1325356200 and aid IN (SELECT aid FROM album WHERE owner IN (SELECT
uid2 FROM friend WHERE uid1=me() ) order by rand() ) ORDER BY like_info DESC LIMIT 30
Here i used rand() to randomize the albums. You can try to randomize the both queries. Every time u execute these codes it will give very different result and you would notice there are many more pictures with many more likes.

FQL returns only one photo

I use this query:
SELECT pid FROM photo WHERE owner=$friend_id;
It works fine, but for some users(that has more than 1 photo) this query returns only 1 record.
Then i tried this query:
SELECT pid FROM photo WHERE owner=$friend_id LIMIT 10;
But returned result is the same - only 1 record.
Permissions :
user_activities,
user_photos,
friends_activities,
friends_photos,
publish_stream
What i have to do to get correct result for anyone user??
This depends on the friend's privacy settings for the albums and photos he/she shares/uploads.
Also, I noticed that the owner field in the photo table is not indexable but it is in the album table and hence you may need to use something like:
SELECT pid FROM photo WHERE owner = XXXXXX AND aid IN (
SELECT aid FROM album WHERE owner = XXXXXX
)

FQL - Order photos in album by like_count

I'm trying to get the photos of a Facebook album ordered by like count in FQL with a this query:
SELECT like_info, object_id FROM photo WHERE aid="xxxxxxxxxx_xxxx" ORDER BY like_info.like_count desc
But I get an error (#602) like_count is not a member of the like_info scalar.
SELECT like_info, object_id FROM photo WHERE aid="xxxxxxxxxx_xxxx" ORDER BY like_info desc
Does the trick, but I don't know why: isn't *like_info* an object? it is possible to order a query using a member of an object?
Just use ORDER BY like_info. Don't forget to put LIMIT, otherwise query might crash for large number of pics:
SELECT like_info, object_id FROM photo WHERE aid="20531316728_324257" ORDER BY like_info desc LIMIT 10
Run in Facebook API explorer

Single fql query get latest photos for array of friends

SELECT object_id, src_small FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner = me())ORDER BY created DESC LIMIT 1
in the example me() can be replaced with any friend_id , order by "created" is also posible
I am looking for a way to declare friend_id's as array and avoid using fql.multiquery (very slow and got timeouts using node.js)
Thanks