I have a big problem with Facebook FQL, if i do
select message from stream where source_id=175102475936031
I can get the correct data, if i do this
select message from stream where source_id IN(175102475936031,etc,etc,etc)
I got a empty JSON, why? is there any alternative to this select? I have to read the messages from multiple events.
Is your problem solved?
"IN" query is a supported feature of FQL. I have tried it multiple times.
Only needs to have:
column indexable
needs to have permission to access data
data should be present for at least one column :P
select message from stream where source_id IN( 175102475936031, etc, etc, etc)
"NOT IN" is not a supported feature of FQL. Ref: http://forum.developers.facebook.net/viewtopic.php?id=1420
Related
Hi i have written a query by which i can fetch posts,actor_id,comments and other columns required from stream table. But i want to fetch user's name also along with actor id and other columns in a single query.
My queries is :
select message,created_time,actor_id,attachment,comments,created_time,impressions,likes,message,message_tags,place,share_count from stream where source_id in (any_page_id)
I want to add user's name also from user table along with this list of columns i am fetching from stream table in a single query so that i can handle it in a single json file. .
Also in comments we will get several user's id with comments as from_id. Can we get username for this from_id also. Is this possible, i know we cannot use join in FQL. Or i am missing something or in a wrong approach. Please help me out. Thanks in advance.
Updated
Now i am able to get actor_id and other fields of the post together along with user's name at the end in the same json using multi-query. Something similar to :
fql?q={"query1":"select+message,created_time,actor_id,attachment,comments,created_time,impressions,likes,message,message_tags,place,share_count+from+stream+where+source_id+in(any_page_id)","query2":"select uid,name from user where uid in (*#query1* "}
But now i am not able to get the user's name and user's id who are there in the comments of the post in the same json.
I need to retrieve among other data all the shares a person has done on his facebook account during the past year, 2012 in my case.
I found that shares are accessible via FQL table named "stream", selecting stream.type = 80. Using also the where clause on "created_time" and source_id should do the trick :
SELECT post_id,message,likes,attachment
FROM stream
WHERE source_id = me()
AND created_time > 1325397600
AND type=80
ORDER BY likes.count desc
Fact is... When querying the stream table, facebook's engine seems to need a limit. If you don't provide one, no result. I guess it's because if no limit is set, response times could be veeeery long... Anyway I'm sure they have many reasons for that. So :
SELECT post_id,message,likes,attachment
FROM stream
WHERE source_id = me()
AND created_time > 1325397600
AND type=80
ORDER BY likes.count desc
LIMIT 100
But: this limit parameter seems to be applied before some of my where clauses, unlike in SQL statements such as SQL server, it means that what fb does with my example query is sequentially :
take 100 elements from stream quite randomly, of any type (could be status, shares, photos, places, posts on your wall from friends, etc.) and any time. Actually, my source_id clause seems to be applied before limit.
then filter by type 80 and created_time, but not sure how
In my case, I need all shares from year 2012, but I can never be sure that some arbitrary limit set to 2000 or 5000 will catch all one's 2012 stream elements before applying the filter.
Maybe there is an other way ?
Thanks a lot for your help.
In the documentation it mention only AND and NOT.
The reason I'm trying to use OR is to break a large results sets into multiple queries and make sure the queries doesn't fail.
For example:
This query return one result:
SELECT post_id FROM stream
WHERE (source_id = '100000462790227' ) AND strpos(lower(message),'sweet') >=0
AND (filter_key = 'others')
But when I added OR on the filter key I got empty results
SELECT post_id FROM stream
WHERE (source_id = '100000462790227' ) AND strpos(lower(message),'sweet') >=0
AND (filter_key = 'others' OR filter_key = 'nf' )
Is it the OR, or do I do something else wrong?
I finally understood what is the core issue.
Stream table filter_key 'other' and 'owner' works only on one source_id.
My original query had also OR on multiple source_id something like (source_id = '100000462790227' OR source_id = '12345670' ).
This combination return empty results!!
Here are my conclusions and observations:
First "OR" is supported by FQL.
One issue I saw "Graph API explorer" fails sometime while iOS SDK calls succeeded
If you limit the call with " LIMIT X" where X is under 100 you'll get an answer also on the second query. There are few posts on the issues related to large result set and what is the right limit (the one I read are all based on trial and error).
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
We are encountering an issue during the current Hackathon in my company. We access to our newsfeed through the FQL.
When we try to access to some old (but not so much!) informations, we are confronted to a problem: sometimes we have some datas returned, sometimes not.
That's a big deal for us cause it makes our project non reliable.
Example:
fql?q=select source_id, message, attachment, created_time from stream where filter_key="nf" AND created_time < 1323648660
Sometimes returns:
{
"data": [
]
}
Sometimes returns a list a 25 datas as expected.
Look like a wrong cache management?
Is this an open bug for FB ? It's kind of critical.
Hope you will be able to help me,
Regards,
François JAGUELIN
Limit the source_id to one user, for example:
fql?q=select source_id, message, attachment, created_time from stream where filter_key="nf" AND created_time < 1323648660 AND source_id = XXXX
When you don't limit the source_id to one user, the time you query over is greatly reduced. If you need to query over multiple source_id's, pack single source_id queries into a multiquery.
From FbDevWiki...
*The stream table is really two concepts built into one table. If you specify a filter_key and/or multiple users, the results will behave like the stream in Facebook's home page. If only one user is specified, and no filter_key is specified, the table will assume that you want a profile-like view, and all that implies.
Those behaviors differ significantly. For example, the homepage-like view only aggregates data over the last few days. The profile-like view gets much older data from our databases.*