HOW GET FRIENDS ID IN GROUP [closed] - facebook-fql

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I use this code for get my friends where i'm a member of.but not work...!
select uid2 from friend where uid1 IN (SELECT uid FROM group_member WHERE gid = '111111111')

this should work:
select uid,gid from group_member where gid in (select gid from group_member where uid=me()) order by gid
It get all the user id and group id from the group where group id is in a group in where you are member.
BUt I suggest you to split it in 2 query: get the ids of the group where you are in and then get, for each group, the ids of the members
select gid from group_member where uid=me()
and then loop through the results
select uid from group_member where gid ={group_id}
for the users data:
Pay attention: more the query is complicated, more will be the time needed
select name from user where uid in(select uid from group_member where gid in (select gid from group_member where uid=me()))
so i suggest, for each group:
select name from user where uid in(select uid from group_member where gid ={group_id})
here is the user table reference so you can add the fields needed in addition to 'name'

Related

Why I can't retrive "likes_count" if I have "friends_likes" permissions?

This:
SELECT first_name, last_name, likes_count FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY likes_count ASC
I'm using the Graph Explorer. My access token has "friends_likes" and "user_likes" enabled.
However, that query for the active logged in user (me) works.
SELECT first_name, last_name, likes_count FROM user WHERE uid=me()
The query
SELECT first_name, last_name, likes_count FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY likes_count DESC
works perfectly fine for me. Please note that users have the possibility to deactivate the access to their data for apps their friends are using. That's why you'll see for some of your friends null as result value!

Get events created by friends (but returning their names too)

I can get events created by my friends:
SELECT eid, name, start_time, pic_cover.source, location, venue FROM event
WHERE creator IN (SELECT uid2 FROM friend WHERE uid1=me())
But I want to get my friends names asociated to that events. How can I think of that?
As FQL doesn't support joins between tables, the only solution I can think of is that you match the names of your friends and the events they created in your application.
Therefore, you'd need to issue two separate statements:
SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())
and
SELECT eid, creator, name, start_time, pic_cover.source, location, venue FROM event WHERE creator IN (SELECT uid2 FROM friend WHERE uid1=me())
and then match them via uid (from the first query) and creator (from the second query).

FQL Multiquery Returned Info

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.

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)'
}

With Facebook API, can I see my answers to the questions?

I would like to see how I was answering questions, asked in some Facebook group I am a member of. Is there a way to do it with the API?
Follow the steps:
First:
your application need permission to user_questions and user_groups
Second:
you can use a multi-query to get all yours questions, answer and voters with basic information.
Third:
Use https://developers.facebook.com/tools/explorer to check the data
And the end, use this query:
fql?q={
"questions":"select id,question from question where owner= me()",
"options":"select id, question_id, name,votes from question_option WHERE question_id in (select id from #questions)",
"option_votes":"select voter_id, option_id from question_option_votes where option_id IN (select id from #options) order by voter_id desc",
"users":"select uid, name, first_name, middle_name, last_name, sex, locale, pic_small_with_logo, pic_big_with_logo, pic_square_with_logo, pic_with_logo, username from user where uid IN (select voter_id from #option_votes)"
}
Note: the fields "uid, name, first_name, middle_name, last_name, sex, locale, pic_small_with_logo, pic_big_with_logo, pic_square_with_logo, pic_with_logo, username" is public access and don't need a token
You can query the question_option_votes fql table.
However you need to have the appropriate permissions to do so:
To read options from the question_option table you need the following permissions:
user_questions for questions posed by the current user.
friends_questions for questions posed by friends of the current user.
I doubt that, unless your an admin of that group, you would not be able to get that data.