Querying for past events using FQL - events

I'm trying to access the past events of a given user. I'm using the following FQL query: SELECT eid, name, pic_square, start_time, end_time, location FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid = me() AND rsvp_status != 'declined') AND start_time < 1338974650 ORDER BY start_time DESC LIMIT 0,20 (1338974650 is supposed to be the current UNIX timestamp). This works fine. However, facebook only returns a set of 4 events in my case, whereas facebook.com displays a lot more. Why is that?

Yes. Facebook severely limits the amount of past items returned by an API call. When I visit one of my pages, I see over 75 events listed on the past events page. When I query the page's events using either FQL or Graph API, I only get 2 events. My guess is Facebook has a separate table that stores past events that isn't available via the API.
BTW, You can make your code simpler by replacing your timestamp with now().

if you query the event_member table by passing the uid, you will get all the events that were CREATED by the user. if you query the table by passing one eid, it gives you the members of the event and their rsvp statuses.
EDIT: try setting start_date > 0 as stated here it should show you ALL the events.

Related

Showing a default Distinct ID in Mixpanel instead of Mixpanel's own arbitrary choice

In Mixpanel, Users can have multiple Distinct IDs that can be merged under 1 identity. The User is identified with a default Distinct ID, which we’ve noticed is the first one created, not the most recent or one that we would explicitly prefer as the default.
Is it possible to set a default/primary Distinct ID?
Also related, once a user signs up, we are using email address as the Distinct ID. If the user changes their email address, would we need to create an alias (we have Identity Merge enabled, FYI), or update the Distinct ID with their new email?
I did read on this support article titled "Moving to Identity Merge" that:
You can no longer control the canonical id for users in Mixpanel
The ID merge system will now determine which distinct_id is used as the canonical id for a user in Mixpanel. Any merged id can be used to query for information about a user with our APIs, but the results of the query may return a with different canonical distinct_id value than the one used in the query.
I had a similar issue, we use a server-side implementation but this should apply to client side as well, my flow was:
send some anonymous track() events with anon_id & distinct_id uuidv4. Let's say the anon_id is: abc-123
authenticate user (now we have access to user_id)
call identify() with user_id and anon_id
send some track() events with our internal user_id as the distinct_id. For example the user_id is: 1001
We noticed that the default mixpanel canonical distinct_id would always be abc-123, not 1001 like we wanted.
After playing around with the mixpanel API I have discovered that if you create the user profile before identifying, the problem seems to be fixed.
mixpanel.people.set(distinct_id, props);
mixpanel.identify(); // our api is identify(user_id, anon_id)
Going through he flow again, the canonical distinct_id is now 1001 instead of abc-123. I believe this fixes it because creating a profile for the user sets the canonical distinct_id (no source on this though).
To be clear, the flow afterwards is:
send some anonymous track() events with anon_id & distinct_id uuidv4: abc-123
authenticate user
call mixpanel.people.set(distinct_id, props) // distinct_id = user_id
call identify() with user_id and anon_id
send some track() events with our internal user_id: 1001
Then 1001 should be the default canonical distinct_id instead of abc-123.

Facebook graph api Events and Venue Information, sometimes it only returns venue id when the event was created in a known venue

I'm creating an app in Titanium that uses the Facebook Graph API to get all the users events, however, the venue information, it only brought to me, after I was very specific about the field, and some times, a lot of the times, when the Event was created in a known location, it only brings the venue_id, and when I query the venue(via http://graph.facebook.com), then it gives me the venue location details, more importantly, the latitude and longitude of the thing.
Is it possible to bring the information of the venue in the same response?
Also, it only brings the events that the user is attending, is there any way to show the events recommended to him also?
Ti.Facebook.requestWithGraphPath('me/events?limit=5000&fields=id,owner,name,description,start_time,end_time,location,venue,privacy,updated_time', {}, 'GET', function(e) {
obj = JSON.parse(e.result);
Ti.API.info('Events: '+JSON.stringify(obj));
}}); // Facebook Events
Also, it only brings the events that the user is attending, is there any way to show the events recommended to him also?
Not sure what exactly you mean by “recommended” … if you mean events the user has been invited to, then you can query the FQL event_member table with the user id.
You can kind of “join” the info from the table above with the event table by selecting from that using WHERE eid IN (SELECT … FROM event_member WHERE …)
Is it possible to bring the information of the venue in the same response?
Using a multi-query you can do it, similar to as it is described here: FQL: query for event table returns venue.name instead of venue.id

Getting events that a certain profile is attending

Im trying t get some info for some events that certain profile rsvp status is attending but it retrieves blank. Maybe is something about access tolken or whatever.
This is my current fql
SELECT name, pic, start_time, end_time, location, description
FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 100003454558689 AND rsvp_status = 'attending')
ORDER BY start_time asc
But it retrieves blank. How can I fix it?
Well your code is good, you just have to make sure you have the user's rights to get that data. So go to the facebook graph explorer, and pop in your code, but this time change the UID to me(). Why does that work?
Your access token, granted by the Facebook app, determines what user data you can see on Facebook. The Graph Explorer by default shows you your own data.
So make sure that you have the right permissions for event data. You can test it by the Acess Token drop down on the Graph explorer.
Here is a list of permissions: https://developers.facebook.com/docs/authentication/permissions/
Looks like you need "user_events"
So it might be nothing wrong with FQL, but something in the auth process. Good luck.

Fetch Facebook Event using location

I am able to fetch user event but i require to fetch event using location wise like event in usa , uk , india.
How can fetch event location or b/w date range in Facebook
Way #1: Graph API using the event object From: http://developers.facebook.com/docs/reference/api/event/
When you call the graph API using https://graph.facebook.com/{EventId}?fields=location you should get back a location if it was specified by the event admin. You can then try to see if that location is in the area you're looking for. If not, then move onto the next one.
Way #2: Graph API using the event fql table From: http://developers.facebook.com/docs/reference/fql/event/
When you call the graph API using https://graph.facebook.com/fql?q=SELECT name, location FROM event WHERE eid={EventId} you will also get back the event and location. If you want to be tricky and get a listing of all events for an authenticated user, then you can do FQL such as SELECT name, location FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid=me())

Facebook API get events CREATED BY friends

I am developing facebook app which needs to retrieve events created by some of my friends.
Standard SQL query would look like this:
NSString *fql1 = #"SELECT "
#"eid, name, tagline, id, pic_small,host, description, start_time, creator "
#"FROM "
#"event "
#"WHERE "
#"creator = 1111111111 OR creator = 2222222222 OR creator = 333333333";
Facebook allows only to filter tables by indexed fields (which is eid in this table). I assume I could to construct multiquery. Anyone could help with it? I spent some time googling it with no look. I need only one query so learning whole fbl for this has no sense for me at the moment.
BTW: there is a function events.get - you can filter by uid (documentation says):
parameter: uid - Filters by events associated with a
user with this uid.
ASSOCIATED In what sense? are those creator's uids?, invited, attending or maybe? Why facebook documentation is so frustrating?
When I try events.get with uid parameter it returns result with different creators ids than uid parameter.
Graph API function: uid/events returns events user has been invited to, attended or other status but NOT necessarily created by him.
What am I missing here? I granted necessary permissions to my application, it connects, gets friend's event lists but not the events I want.
Seems so simple but I con not find straight-forward solution.
I'd appreciate any help.
You can do something like this:
SELECT
eid, name, tagline, pic_small,host, description, start_time, creator
FROM
event
WHERE
eid IN (
SELECT
eid
FROM
event_member
WHERE
uid=111 OR uid=222) AND
(creator=111 OR creator=222)
Basically this says get the events user 111 or 222 is a member of and of those, only return the ones they've created. Because eid is an indexable field, FQL is okay with this, and is happy to do the additional (creator=111) trimming for you.

Resources