FQL Get All Attendees of All Events for a particular user - facebook-fql

So I've done a bit of reading up on the FQL documentation, but I haven't managed to find the answer to my current problem. Given a single user, I want to get back a list of attendees (per event) that are going to events that the user is also attending.
NOTE: (I am using a StringTemplate, so I provide the proper uid through the render function later)
With this query, I am able to get all the events for a particular user.
SELECT eid from event_member WHERE uid={{}} AND start_time > 0
With this query, I am able to get all the users for a single event.
SELECT uid, eid FROM event_member WHERE uid = {{}}
SELECT uid, eid FROM event_member WHERE eid in (SELECT eid FROM #a)
However, when I try the following query, which I found here: Facebook Graph to show Event Attendees
SELECT eid, uid FROM event_member WHERE eid IN (SELECT eid FROM event_member WHERE uid = {{}} AND rsvp_status = {{}})
I am returned with nothing. Any ideas? Thank you for your time and help!

Ok, so after some more research, I've decided to use the Facebook Graph API instead. This is what people are moving towards, eventually, so it's best to get on board.
The query I used in the graph api to get all attendees for all events that a particular user is also attending was:
https://graph.facebook.com/v1.0/{{}}?fields=events.since(0).fields(name, attending)
This query will return the events the user is going to in addition to all of the other attendees per event.

Related

FQL query limit

I was trying this simple query on the Graph Explorer
SELECT eid FROM event_member
WHERE (uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
OR uid = me())
and it returns "error: Request Failed."
Then, I started reading here and some forums and it had to do with the limits, so I've tried limiting by 20 my friend list and it worked.
Which is the limit? and where (the query, or the results given)? There's nothing in the documentation as far as I know.
EDIT:
What if I order my whole friends by mutual_friend_count and then limit by 200? I also added start_time>now(). It's not the best way to find the closest friends, but it doesn't need permissions to access your stream (to check likes and comments from friends).
SELECT eid FROM event_member
WHERE (uid = me()
OR uid IN (SELECT uid FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()
ORDER BY mutual_friend_count DESC)
LIMIT 200)
)
AND start_time > now()
Is it too many queries inside another one? They are three actually.
It isn't efficent
in some cases. For example, in my case, the top mutual friends lives
in my hometown, and I'm interested in events from my actual city.
Imagine I limit the events retrieved by only 5 per user. It shouldn't be so hard ONLY IF the user had a list of upcoming events he/she is attending/unsure.
For example, doing graph.facebook.com/user-id/events "seems" to work like that.
However, I guess reading from event_member table it's not so easy because it would traversing a large database of events and checking one by one if any friend of mine is in there. Am I wrong?
The limits are as far as I know (and you wrote it as well) not documented. I'd recommend that you use the
LIMIT start, end
in your subquery as follows
SELECT eid FROM event_member
WHERE (uid IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 0,24)
OR uid = me())
A best practice that I use is to get the number or friends in advance, and then create "breakdown queries", i.e. you've got 187 friends and the desired limit is 25 per query, then you'll need to 8 "breakdown queries" to get the whole event list from your friends. This can also be done via a batch request (but friends need to be counted first in a separate query).
The general limit of these calls on Facebook's side are either the processing time or the length of the result I guess...

FQL to Get public event AND stream

Im trying to get and events stream. More specifically the posts and comments about the particular event. I can get the event with no problem.
SELECT eid,pic, name, start_time, location, ticket_uri, venue FROM event WHERE creator =
What I need are the comments/stream/posts underneath.
I've spent a few days on this with no luck.
Here is a sample page Im trying to get the info from:
https://www.facebook.com/events/336787446434356/
I want all the pics, vids comments etc..
Thank you
You can use the following FQL to retrieve posts related to a particular event:
SELECT post_id, message FROM stream WHERE source_id = {Event_Id} LIMIT 500
Similarly, you can perform the following multi-query to retrieve the comments:
SELECT text FROM comment WHERE post_id IN
(SELECT post_id FROM stream WHERE source_id = {Event_Id} LIMIT 500)
Replace the {Event_Id} with the Id of your Event.

get past events through the graph api

I can't seem to be able to access past events in the graph api, it only seems to give me access to the current events, either the events API is broken, or facebook does not provide access to past events, but there is nothing in the docs that would suggest that...
I'm having a similar problem. There is a workaround using FQL, though it will only display current events and past events from the last 2 weeks.
Example Query:
SELECT name, pic_small, eid from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())
You need to set "start_time" condition in your query.Works for me.
FQL example that retrieves current & past events :
SELECT name FROM event WHERE eid in (
SELECT eid FROM event_member
WHERE uid = {you page or user id here}
AND start_time > '2001-11-02T12:35:00+0200'
)
Since FQL doesn't support ( Select * ), address FQL manual to query more fields https://developers.facebook.com/docs/reference/fql/
I'm having a similar problem. There is a workaround using FQL, though it will only display current events and past events from the last 2 weeks.
Example Query:
SELECT name, pic_small, eid from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())
It turns out the Facebook pagination is broken for events, but there is a walk around by setting the "since" parameter to 0 and paginating upwards ans oppose to backwards...

What's the query to get a list of a user's own posts that they have Liked?

Yes, I know that it's unusual for a user to "like" their own posts but that's what I'm looking for. I also know that you can't query the like table by user to get everything they've liked but that's not what I'm after. I just want their own posts (and later, photos) that they've liked.
I've clearly gotten pathetically rusty in my SQL skills--playing around with statements based off of the examples I've found:
SELECT source_id,message,created_time FROM stream WHERE source_id=me()
and
SELECT actor_id, post_id, message FROM stream WHERE uid IN (SELECT uid2 FROM like WHERE uid1=me())
I imagine what I want is either trivial to do or currently impossible. I expect the former.
To get the post ids that the user likes, it would be something like:
SELECT post_id
FROM like
WHERE object_id in (SELECT source_id FROM stream WHERE source_id=me())
AND user_id = me()
You could expand this to also include photo ids. And you could nest it another level deep to get more post info by using the like's post_id field.

Get a list of events owned by a facebook page

Does anyone know how I can get a list of events owned (created) by a Facebook page?
I seem to be able to use the "graph api" to generate a list of the events an entity is attending. I also looked at FQL, but it seems to require that the 'where' clause is an indexable field (and, naturally, the id is the only indexable field).
For bonus points, we'd be able to do this without any authentication. (Though I'm resigned to the fact that I'm likely going to need at least a permanent access_token.)
If anyone knows how to do this I'd be eternally grateful.
All FQL data access requires authentication, so forget about those "bonus points".
This is going to require some post-query handling as, like you said, the FQL WHERE clause only respects indexible fields and the owner.id field is not indexible. Thus, we first begin by identifying events the user is a "member" of and loading the owner information for those events.
SELECT id, name, owner.id FROM event WHERE id IN (SELECT eid FROM event_member WHERE uid = XXX)
Once the query returns a dataset, we must manually check for rows in which owner.id is equal to uid.
Looks like you have to first query the event_member table, using the uid
http://developers.facebook.com/docs/reference/fql/event_member
and then once you got the eid of the events you can query the events table where the eid is indexed
http://developers.facebook.com/docs/reference/fql/event
and I'm sure you can use the first as a subquery of the second query like var query = FB.Data.query("select name from event where eid in (select eid from event_member where uid = {0})", user_id);
This one does it
select eid from event where creator=".$facebookPageId." and eid in (select eid from event_member where uid=".$facebookPageId.") ORDER BY start_time DESC
This link has a good tutorial on FB events and many more on C#.
http://blog.impact-works.com/2011/07/
But he uses a dll which he created. But as soon as you get the idea out of the blog, you can use Facebook c# Sdk to develop whatever you want to develop.
And all these info is valid for you IFF you are developing in c# my friend.
use this get request
https://graph.facebook.com/'your facebook page ID'/events?access_token=' your application token'&limit='number of events wanted'&after=1&fields=owner,name,description,cover,id
first you must create a facebook application and get its "app token"
In the fileds column you can specify the details you want about the event using the names in facebook API https://developers.facebook.com/docs/graph-api/reference/event/