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

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).

Related

FQL: Get comment data WHERE object_id={a known object_id} works, but WHERE id={a known comment XID} does not?

I'm using FQL to get comment data from webpage with a Facebook comment box. I use the graph to get the object_id, then use FQL to get all comments with that object_id. However, if I want to pull data from a specific comment using its id (sometimes referred to as an XID) the FQL returns 0 results.
According to https://developers.facebook.com/docs/reference/fql/comment/ the id should be indexed, so this query should work:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+id={some known XID}
But it doesn't. BTW, THIS query does work:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+object_id={some known object_id}
It is irritating how I can't pull query for comments using time or fromid or anything other than object_id, id, post_id, and parent_id... but in practice only using the object_id returns anything.
has anyone else run into this problem? Is my XID query wrong somehow, or is the id only indexed on certain kinds of comments, and not webpage comments for no inexplicable reason?
This one I managed to solve with trial and error. I had to put the id in single quotes. It's odd, I could query the object_id without putting it in quotes, but not the id. This is sort of what the working FQL looked like, except with a valid access token:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+id='#########_####'
as opposed to:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+id=#########_####
which failed to return any results.
Thanks for being consistent, Facebook :(

FQL - Data fetched/unfeteched almost "randomly"

Her'es the situation, I run the following FQL code (in the debugger currently) to search my stream for specific items:
SELECT attachment,description,message
FROM stream
WHERE
(source_id=me())
AND
strpos(message,'shakshuka') >=0
Things are alright - I get results, woohoo.
BUT (!) :
When I change the condition, to something that should be very simple-
to support also my friends posts, suddenly.. I get nothing.
For example:
SELECT attachment,description,message
FROM stream
WHERE
(source_id IN (SELECT uid2 FROM friend WHERE uid1 = me()) OR source_id=me())
AND
strpos(message,'shakshuka') >=0
I could run these twice but... why?!
I don't want to.
There's something wrong with all considering limitations and FQL queries, after reading some posts # FB dev forums,
I just added LIMIT 500 OFFSET 0 to the end of the query and it works like magic.
I guess the tech guys # Facebook need a little extra hand in all regarding to stable their own "SQL" version.

fb:comments-count return wrong value

I use
<fb:comments-count href=http://e-drpciv.ro/intrebare/963/></fb:comments-count>
I also try with quotes
<fb:comments-count href="http://e-drpciv.ro/intrebare/963/"></fb:comments-count>
and the return is always zero:
/**/ FB.__globalCallbacks.fdd5cbfe8aa94c({"data":[{"name":"index_link_stat_url","fql_result_set":[{"url":"http:\/\/e-drpciv.ro\/intrebare\/963\/","commentsbox_count":0}]}]});
Some other links report less comments than real.
Eg. http://e-drpciv.ro/intrebare/35 report only 3 comments
I need to update something in my code? Or is just a facebook issue and I need to wait?
This problem persist for two days.
If someone shares someone else story it wouldn't show you the comments of that previous share in your /home, but when you query the fql to get comment_count of that object "SELECT comment_info FROM photo WHERE object_id = 1234567890" it will count you all comments from all shares, this is why when you query the /home with FB API you will find posts without comments but with the SELECT ... it will return you positive number of comment's count. i belive that there is some join to make or to can get only the current user.

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

FQL subquery breaks top query and never returns

We have a FQL query that used to work and stopped somewhere around Oct 16. No help from Facebook on this.
This code used to work:
SELECT object_id, metric, end_time, period, value
FROM insights
WHERE object_id IN
(
SELECT page_id
FROM page_admin
WHERE uid=123
AND page_id<>456
AND page_id<>789
)
AND metric="page_audio_plays"
AND end_time=end_time_date("2011-11-11" )
AND period=86400
If I run the inner Select, it returns a large list of page_id's. IF I remove the inner select and replace with a list of comma seperated id's like this:
...where object_id in ( 123, 456, 8778, 999)
The overall query runs.
With the original code above, the query never returns and times out.
Question: Is anyone aware of something on FB side that broke around the middle of October in this regards? Or is there something inherently wrong with doing a subquery like this?
Any suggestions on how to work around?
Net: query returned TOO much data. If you have this problem, break up the result set somehow so it returns a smaller set of data. Would be nice if API returned some discernable status telling you so but....