FQL Multiquery Returned Info - facebook-fql

I'm trying to use an FQL Multiquery to obtain my most recent Facebook question and options with one query using an http request.
So far the query I tried to use is:
SELECT name, votes FROM question_option WHERE question_id IN
(SELECT id, question FROM question WHERE owner = me()
ORDER BY created_time DESC LIMIT 1)
Unfortunately this only returns the name and votes from the outer query and not the question text from the inner one. Is there a way to retrieve all 3 without making 2 queries?

What you posted isn't a multiquery. A proper multiquery should get you what you want:
{
'question_detail':
'SELECT id, question FROM question WHERE owner = me()
ORDER BY created_time DESC LIMIT 1',
'question_answers':
'SELECT name, votes FROM question_option WHERE question_id IN
(SELECT id FROM #question_detail)'
}
You'll need to get rid of the whitespace for this to properly execute.

Related

Facebook FQL Query Order By Using Multiple Columns

I have a Facebook FQL query which in which everything is going good but what I want is to Order the results by 2 columns.
Here is the last line of the script and until this it is working.
IN (SELECT aid FROM album WHERE owner=133025843429181)ORDER BY created desc
What I want is to order it by created desc and like_info desc, so this is what I am trying and it returns an error.
IN (SELECT aid FROM album WHERE owner=133025843429181)ORDER BY created desc, like_info desc
This is not working. I tried to remove the comma in between and still not working
IN (SELECT aid FROM album WHERE owner=133025843429181)ORDER BY created desc like_info desc
Any solution for this?
Please try the below code: It might be the fix you need
IN (SELECT aid FROM album WHERE owner=133025843429181) ORDER BY (created desc * like_info desc) DESC
This isn't possible.
FQL can handle simple math, basic boolean operators, AND or NOT logical operators, and ORDER BY and LIMIT clauses. ORDER BY can contain only a single table.
https://developers.facebook.com/docs/technical-guides/fql#query

fql OR and order by desc with offset

I have some issue with a Facebook's fql request :).
When I request like this
SELECT uid, profile_url
FROM user where contains('potatoe') OR uid in(select id from profile where contains ('potatoe'))
ORDER BY mutual_friend_count desc LIMIT 0,2
I have always the same results, even if I change the offset...
But
If I change DESC to ASC the "offset" works...
If I change OR to AND
and let the order by desc => the "offset" works too!
Something is wrong with my OR/desc/offset combo?
Or I just have misunderstood something with "or" operators? :/
Thanks a lot.
You should write your FQL query like that:
SELECT uid, profile_url
FROM user
where
uid in(select uid from user where contains ('potatoe') )
OR uid in(
select id from profile where contains ('potatoe')
)
ORDER BY mutual_friend_count desc
LIMIT 0,2
FQL couldn't interpret in boolean expression the result of "contains", so your OR operator failed here...
I think the problem is your query is asking the same question two different ways:
Show me all my friends user profiles that contain 'potatoe' OR
Show me all profiles that belong to users who are my friends that contain 'potatoe'.
Simplify your query to this and see if it works as expected.
SELECT uid, profile_url FROM user WHERE contains('potatoe')
ORDER BY mutual_friend_count DESC LIMIT 0,2

Getting friends status updates and comments using facebook api

Hi i am new in using facebook api
i want to get the friends status based on following criteria
Get all the friends details (name, uid, status_message, posted_date) whose status update has more than 15 comments/likes
following query is giving all friends status updates
SELECT status_id, uid , message FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Above query returns all my friends updates but i want to include the comments and likes on those updates in the response so that i can check the count on my side
there are comments table and likes table also in the api both might have foreign key relationship with the status_id column
Can we write a full query with joins like SQL
You can't do JOINs in FQL, but you can approximate them with a multiquery:
{
'status': 'SELECT status_id, uid , message FROM status
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())',
'comments': 'SELECT post_id, fromid, time, text FROM comment
WHERE post_id IN (SELECT status_id from #status)'
}

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

Facebook's fql improper ORDER BY sorting

I have this fql query:
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls
FROM link
WHERE owner IN (SELECT uid2
FROM friend
WHERE uid1 = me())
ORDER BY created_time DESC
LIMIT 0,200;
It's supposed to display last 200 posted links by my friends, but it displays them ordered by owner id ASC then by created_time DESC.
Is ORDER BY in fql limited to one use? How can I make it work?
I suspect the problem is the LIMIT statement. FQL has some odd internal behaviors to optimize their own internal API.
Try removing the LIMIT statement and just give it a specific AND created_time > <point in time> and see if it orders properly. If so, that's why.