Get Facebook Events I don't Own - facebook

I am building a site that needs to query Facebook events. I need a list of events I do own, and list of events I don't own. The problem is that querying the Events object via FQL requires that I pass one of the indexable fields. Those are creator, name, and eid. This is fine when I need my events (creator = me()). However, when I need events I don't own I can't seem to use a SQL like statement in (creator <> me()).
Any suggestions on how to do this?
SELECT name,start_time,end_time,location,eid,pic,description FROM event where creator = me() and start_time >= 1370106582

It's not as straightforward as I would like but this query works.
SELECT name,start_time,end_time,location,eid,pic,description FROM event where eid IN
(SELECT eid FROM event_member WHERE uid = {UserId} and inviter and rsvp_status = 'attending')
If you query for event_member by the Users Id the Inviter field with be null for events in which they are the owner. In FQL if you just add 'Where {field}' in a where clause, it returns all the results in which that field's value is not null. I know that's a bit confusing but it works.

Related

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

getting users attending event data from facebook using FQL

im having trouble getting information i want with fql.
i want to get the name and uid of all the people rsvped "attending" to a specific event sorted by name.
i know how to get all uid of the users attending to an event using the following query:
SELECT uid FROM event_member WHERE eid = ... AND rsvp_status = 'attending'
unfortunately event_member table doesn't have the name of the uid
and i know how to get the name and uid from event attenders using graph api, but the ther iss no way to get it sorted by name as far as i know.
your thoughts?
found the answer, i forgot there was a table called "user". the solution is
SELECT uid, name FROM user WHERE uid IN
(
SELECT uid FROM event_member WHERE eid = "EXISTING_EVENT_ID" and rsvp_status= "attending"
)
SORT BY name
Try out FQL Query like
SELECT name, venue, location, start_time FROM event WHERE eid IN (
SELECT eid FROM event_member WHERE uid = "USER_ID_HERE" and rsvp_status="attending"
);

Facebook API: How to use Event's venue.id?

Facebook events have a venue.id, how can I use them? Can they be converted to actual addresses?
For example, the venue id for this event is "132764236748017". I found it by running the following fql code,
SELECT venue FROM event WHERE eid IN (SELECT eid from event_member WHERE uid= me())
Is 'venue id' the id of a place?
EDIT: I found the answer
I could use 'SELECT name,description,geometry,latitude,longitude,checkin_count,display_subtext FROM place WHERE page_id=110506962309835' where page_id is the same as venue.id

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.

Query of past events for a "like" page is not returning full list (as shown on actual page)

The code used to query (below) has not changed since before it was working correctly, but the page suddenly started only displaying one of the many past events. Has the functionality of the QL changed in some way or is this just a bug that I should wait and see if it passes?
SELECT name, pic, start_time, end_time, location, description, eid
FROM event
WHERE end_time < now()
AND eid IN (
SELECT eid
FROM event_member
WHERE uid = XXXXXXXXX )
ORDER BY start_time DESC
I'm not totally sure, but FQL's documentation on event_member might be the key. Have you attempted running only the internal query (SELECT eid FROM event_member WHERE uid = XXXXXXXXX) alone without the wrapper to see what it's returning?
FQL documentation for event_member states that
If you do not specify a start_time, only events in the future will be returned.
EDIT: I take this to mean that you may, currently, need to specify start_time < now() in there, or something of the like.
(Though, if that's case, I'm not sure why you're even getting the one item returned because that would conflict with your end_time < now() statement).
My first suggestion might be to spit it into multiple queries using FQL multiquery and make sure that the event_member query is returning what you'd expect.
Something like:
"event_members":"SELECT eid
FROM event_member
WHERE uid = XXXXXXXXX"
"events":"SELECT name, pic, start_time, end_time, location, description, eid
FROM event
WHERE end_time < now()
AND eid IN (SELECT eid FROM #event_members)
ORDER BY start_time DESC"
See that event_members holds all the entries you're hoping for - if so, find the issue in the 'events' query, if not, find the issue in the 'event_members' query.