33

I've been trying to figure out how to do this, and was thinking it wasn't possible, then found this website: (Removed due to a dead link)

You can search by city there and I have no idea how they do it? The normal graph API's don't allow searching for events by location as far as I can see. Any advice/tips/info would be great!

egfconnor
  • 2,637
  • 1
  • 26
  • 44

5 Answers5

46

Updated 2014-07-02

You can't directly search the Facebook API for events near a location. Since originally giving this answer, the Graph API has made it harder to search for events.

The Elmcity script referenced by the OP does a simple search for a keyword in the event title. Try "Lancaster" for example. You'll get events that have the word Lancaster somewhere in their metadata.

Their query looks something like this:

 https://graph.facebook.com/search?q=lancaster&type=event

You can also search for a non-location based word in the title like "picnic" and the script returns events.

For the problem of actually finding events near a location, in the current iteration the "venue" field is only a string, so it has no relationship to any Facebook place. Running these query returns nothing:

https://graph.facebook.com/madisonsquaregarden/events
https://graph.facebook.com/108424279189115/events

So using a batched request isn't even a possibility.

According to the documentation FQL seems to be a better solution. In the event documentation, the venue.name column is indexable! Easy, right?

Wrong. When you run this FQL query to find events at some location like this:

 SELECT name, start_time, venue FROM event WHERE CONTAINS("madison square garden")

You find that venue.name isn't populated.

Trying any other variation like:

 SELECT name, start_time, venue FROM event WHERE venue.id = 108424279189115

Throws a "statement not indexable" error.

So while building a "Facebook Events Near Me" is the killer app, the only way that it seems possible is to search for common strings for events near you, get those events, then filter out irrelevant events from the result set.

Community
  • 1
  • 1
cpilko
  • 11,792
  • 2
  • 31
  • 45
  • Thank you. I figured out the first part after some research but are you sure you can find events by location? You have the * wildcard in your search, but that doesn't seem to work for events? – egfconnor Jun 25 '12 at 16:11
  • 1
    Sorry. Those queries just return places. You can't directly query events by location using the Graph API. You can do it with FQL: `SELECT eid FROM event_member WHERE uid IN (SELECT page_id FROM place WHERE distance(latitude, longitude, "37.76", "-122.427") < 1000)` – cpilko Jun 25 '12 at 17:09
  • cpilko, could you explain the FQL query in detail? Specifically, I'm wondering how the "uid" attribute works - the doc says it's "The user ID of the user for the event being queried." – thomers Nov 03 '12 at 12:22
  • 1
    The `uid` in the `event_member` table is mis-named. It's a legacy field from when only users could attend events. Now pages (and places) can also be members of an event. The inner query finds the ids of all places within 1000 meters of [Mission Dolores Park in San Francisco](http://goo.gl/maps/kgJVd), then feeds those ids into the outer query, which finds all events at those places. – cpilko Nov 03 '12 at 15:04
  • Why is this answer validated ? it gives you places, but not events. – franck Jul 02 '14 at 09:41
  • @franck: Updated this for you. – cpilko Jul 02 '14 at 14:02
  • FQL query no longer available. https://developers.facebook.com/docs/reference/fql/ – Mykytak Nov 12 '16 at 00:07
  • graph.facebook.com/search?q=srilanka&type=event This is work for me, But this URL gives limited data, i want more data of public event like cover photo, owner name etc. with this query. Any idea? – Ketav Feb 18 '17 at 12:37
  • I build a library to search for events at a specific location: https://github.com/tobilg/facebook-events-by-location – Tobi Apr 12 '17 at 09:25
7

This JavaScript library on GitHub seems like an interesting approach to look at. It uses a places search and then does an events search on those places.
tobilg/facebook-events-by-location-core

Tobi
  • 31,405
  • 8
  • 58
  • 90
studgeek
  • 14,272
  • 6
  • 84
  • 96
  • 1
    Do you think you can figure out a full example? I've tried different formats of /search?type=place&q=*&center={coordinate}&distance={distance}) but it does not seem to work. – FastSolutions Jul 05 '16 at 14:52
  • There's not only a Node module, the core module of that service can also be used in JS frontend applications: https://github.com/tobilg/facebook-events-by-location-core – Tobi Oct 25 '17 at 07:11
3

As of recent. the Events end points have been deprecated due to the privacy issue. Your app will now need to be reviewed first to access events api, when it resumes.

Master Ace
  • 69
  • 2
  • 4
  • Facebook announced this on April 4th, 2018: https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/ – bramchi Jun 18 '18 at 11:57
0

Events and points has been deprecated due to privacy issues. Now you have to review your app before you can access events api. After successful approval you can search events.

Ali Yar Khan
  • 1,231
  • 2
  • 11
  • 33
-4

So what you can do is enter "Events", but you need to enter the date, or tomorrow after that. Then, on the right, in your filters, enter the location field, select other, then punch in the location you want.

Sean
  • 9