1

I am trying to get the last 10 posts from a user's stream. For some reason my FQL query will return two of every post in succession. Here is my code, Pardon the CoffeeScript,

method = 'fql.multiquery'
queries = 'feed' : "SELECT attachment , type , created_time , filter_key,     actor_id, description, message  FROM stream WHERE (filter_key = 'others' OR filter_key = 'owner') ORDER BY created_time DESC LIMIT 10"
params =
    method : method
    queries : queries
FB.api (params) , (response) =>
    #and so on

I am not really sure why this is happening.

d4rklit3
  • 417
  • 1
  • 5
  • 12

1 Answers1

2

FQL can't do group by's, and Facebook stores post stories in various ways, so there are "multiples". The way to get around this is to select the columns you need, and do a "where in" to limit your result set, i.e.:

select 
    attachment , type , created_time , filter_key, actor_id, description, message
FROM 
   stream
WHERE 
   post_id in (select post_id 
      FROM 
         stream 
     WHERE 
          (filter_key = 'others' OR filter_key = 'owner' and created_time < [long-ass unix time])
  )
  • don't believe you can do limits, you should do less than/greater than a date, or parse and sort result set
Anna Billstrom
  • 2,482
  • 25
  • 33
  • This doesn't appear to work. I get "(#601) Parser error: unexpected ')' at position 250." when trying to run this query in the Graph API Exporer. The error seems to be connected to the subquery. – Jude Osborn Nov 20 '12 at 01:08
  • Actually just looks like you have an extra closing parenthesis at the end. – Jude Osborn Nov 20 '12 at 01:21
  • Also "created_date" should be "created_time". After making those two adjustments and adding a timestamp the query works very nicely. Thanks for the info. – Jude Osborn Nov 20 '12 at 01:23