Fetch Facebook Event using location - events

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

Related

Event Sourcing - Data supplied to Command and data saved in Events

I am looking into event sourcing and I have a few thoughts that I need to get my head round.
Take for example an online shop -
The customer adds an item to the basket and saves their order.
The command handler could create an order on the customer aggregate root and add an OrderCreated event which contained the customer id, order id, item id, quantity and unit price. All pretty straight forward but what if the aggregate needed to check to see if that item was on special offer?
If this was for example a basket service would it subscribe to events from the catalog service and store it's own projections of the catalog service which it could then use, so then the basket service would comprise an event store and also some form of projection of the catalog service?
Or if in the example I've just described, if the basket and catalog functionality were part of the same application and they only held event data, then when a customer creates an order the handler would pull all ordered items from the event store via a repository, apply all events to them and then return them to the handler in order to check if the item was on special offer.
what if the aggregate needed to check to see if that item was on special offer?
It needs to execute a query to get the information it needs.
From the aggregate point of view those data are external, so it (or the handler sending the command to it) needs a query to access that information.
How the query work is up to you (there are pros and cons for each way), the query handler can:
Call a repository that loads an aggregate and check for the special offer (you can also think to have event sourcing in just one part of your system and having this part using another way to store dara, or not)
Make a remote call to the Catalog Service API to check for the special offer
Do a query to a local db, that is populated reading events emitted by the catalog service and stored "locally" to the basket service

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.

Querying for past events using FQL

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.

Create an event with latitude and longitude

How can I create a Facebook event in Graph API setting latitude and longitude?
I have tried the Graph API Explorer, using a post method to https://graph.facebook.com/MY_ID/events and parameters.
All works fine, except for latitude and longitude. I also have tried to create a local page with a valid location and set the page_id/location in event's parameters, but that only creates the event assigned to the page.
What is the solution?
The latitude and longitude are part of the Venue data on an event, but when you create the event, they need to be top level parameters.. Once the event is created and you query for it using the /{eventid} query, they will show up in the Venue JSON node.
I have been experiencing the same problem and have found no method of posting event data that results in saving latitude and longitude. What I have discovered is that after an Event is created editing the event - even with no changes - results in a calculation of the latitude and longitude. The resulting calculated values are slightly different than those passed in the post so these values are clearly not related the parameters I passed.

Resources