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

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

Related

Finding friends with specific job title

I'm trying to find all my friends with a specific job title, and no matter what I put in filter, it always return nothing
FQL query:
select name, work.position from user where work and uid in (select uid1 from friend where uid2 = me())
and work.position.id= 103141116410872

Can I get the creator of an facebook event's profile pic, using FQL?

I need to use the following fql to also get the creator's profile pic of an event. The creator column only returns their id, but i'm not sure if there's a way to do both of this nested queries.
SELECT eid, name, location, creator FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid = me())
First you make sure want you want to retrieve.
If you want the name and profile picture of the creator of an event you are in you can use below code:
SELECT name,pic_big FROM user WHERE uid IN (SELECT creator FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid = me()))
But if you need event details also (as you already have that fql) you need to query two separate queries it cannot be done using nested queries

Facebook API: how to get event details

Trying to get the details of all events me/my friends are attending/maybe attending in the coming month (date manipulations in the FQL).
I am also in need of getting those events' feeds for further analysis in my program.
So far I found Facebook API's documentation hardly any helpful.
You can use the event and event_member tables in conjunction with the friend table to get this data.
Eg:
SELECT eid, name, location, start_time FROM event WHERE eid in ( select eid from event_member where rsvp_status != 'declined' and uid = me() or uid in (select uid2 from friend where uid1 = me()) ) AND start_time >= '2012-08-01' and start_time <= '2012-08-31'

Facebook FQL Subquery

Im using the below query to fetch all the events that I have accepted the invitation to:
NSString *eventQuery = #"SELECT eid, name, creator FROM event WHERE eid IN
( SELECT eid FROM event_member WHERE uid = me() AND rsvp_status='attending' )";
This works perfectly, but now I want to get the name of the creator too. Since the creator field is just the userid of the creator I have to do another subquery.
Can someone help me with this?
Thank you so much for your time!
You need to issue an FQL multiquery to get this. I'm not sure of how you do this in Objective C, but the FQL syntax is:
{
"user_events":
"SELECT eid, name, creator FROM event WHERE eid IN
(SELECT eid FROM event_member WHERE uid=me() and rsvp_status='attending')",
"event_creators":
"SELECT name, id FROM profile WHERE id IN
(SELECT creator FROM #user_events)"
}
Your original problem with no "maybe" events getting returned is because rsvp_status='maybe' is incorrect. rsvp_status='unsure' is the correct syntax.

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