Photo tags query response of max 400 elements - facebook

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

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?

a unique combination of fql and graph api

am trying to search the fb posts of a given keyword but need only results with condition of having more than a specific comments count or likes count, i mean the results will only have posts which have a minimum of given value in comments count and likes count.
i tried with many developers but all are saying that its not possible, as the graph api don't offer this kind of method or http call functions.
but what my point is, there will be a possible way to mix both fql and graph and get the results, something like this, but i don't know the exact schema to use.
https://api.facebook.com/method/fql.query?format=JSON
&query=select comments from comment where object_id in
(select comments_fbid from link_stat where url ='http://developers.facebook.com/docs/reference/fql/comment/')
&pretty=1
You can mix Graph API and FQL requests in a single call using batch requests. You have to use the new Graph API url instead of the REST API url you show in your question. You will also need an access_token to get this data.
Facebook does have a comments.count and a likes object for the comment FQL table. That give a numerical comment count you can query against:
SELECT comments, likes FROM comment WHERE object_id IN
(SELECT comments_fbid FROM link_stat WHERE url ='http://developers.facebook.com/docs/reference/fql/comment/')
AND (comments.count > 5 OR likes > 5)

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 search public posts

I'm trying to do a search using FQL.
Using the Graph API, it works but there are more options using FQL.
Using something like
https://graph.facebook.com/search?q=myquery&access_token=mytoken
it work fine.
I'm looking for the equivalent in FQL.
What query I must write in here
https://api.facebook.com/method/fql.query?query=SELECT%20post_id%2C%20actor_id%2C%20target_id%2C%20message%20FROM%20stream&access_token=mytoken
The query above give me that
Parser error: unexpected end of query
I want to search in all public posts.
I've been looking everywhere but I did not found any solution.
Thanks.
For searching public posts for a string, you need to use the Graph API, and then filter those posts in your script. I don't think searching all public posts is possible in FQL. While FQL is more powerful, it is also more limited.
You are getting an error because you don't have a "WHERE" clause in your query. This is required in FQL.
The limit comes in because you must use at least one indexed column in your WHERE query. For the stream table you must specify either a post via post_id, a user via source_id or filter_key, or a live stream via xid. The indexed fields are marked with a * on the documentation site.
For instance, [this FQL][1]
SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key = 'others'
AND strpos(message, 'the') >= 0
will get you all posts that show on your access token owner's wall that have not been posted by the owner, with the string 'the' in them. That is the best you can get. If the post isn't visible on their wall, then you won't get the post.
If you try to leave out an indexed field, FQL will throw a 'Your statement is not indexable' error.
[1]: SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key = 'others' and strpos(message,'the') >=0

Facebook - max number of parameters in “IN” clause?

In Facebook query language(FQL), you can specify an IN clause, like:
SELECT uid1, uid2 FROM friend WHERE uid1 IN (1000, 1001, 1002)
Does anyone know what's the maximum number of parameters you can pass into IN?
I think the maximum result set size is 5000
It may seem like an odd number (so perhaps I miss counted, but it's close ~1), but I can not seem to query more than 73 IN items. This is my query:
SELECT object_id, metric, value
FROM insights
WHERE object_id IN ( ~73 PAGE IDS HERE~ )
AND metric='page_fans'
AND end_time=end_time_date('2011-06-04')
AND period=period('lifetime')
This is using the JavaSCript FB.api() call.
Not sure if there is an undocumented limit or it might be an issue of facebook fql server timeout.
You should check if there is a error 500 returned from FB web server which might indicate you are passing a too long GET statement (see Facebook query language - long query)
I realized my get was too long so instead of putting many numbers in the IN statement, i put a sub-query there that fetches those numbers from FB FQL - but unfortunately it looks like FB couldn't handle the query and returned an 'unknown error' in the JSON which really doesn't help us understand the problem.
There shoud not be a maximum number of parameters as there isnt in SQL IN as far as I know.
http://www.sql-tutorial.net/SQL-IN.asp
just dont use more parameters than you have values for the function to check because you will not get any results (dont know if it will give away an error as I never tried to).