How can I query public facebook events by location/city?
Asked Answered
P

5

34

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!

Phonation answered 24/6, 2012 at 21:51 Comment(5)
Sorry @ArturBodera...I don't know the owner of the website.Phonation
Remove the link then. There's slim chance it'll ever come back at this url, but it could lead to malware in the future.Logway
There you go @ArturBoderaPhonation
Thanks @egfconnor. I really wish there was a solution :(Logway
Yeah...the Facebook app now shows nearby events in it though. I'm guessing they wanted to keep that for themselves or something along those lines.Phonation
O
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.

Obstinate answered 25/6, 2012 at 2:3 Comment(9)
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?Phonation
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)Obstinate
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."Snowonthemountain
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, then feeds those ids into the outer query, which finds all events at those places.Obstinate
Why is this answer validated ? it gives you places, but not events.Gloaming
@franck: Updated this for you.Obstinate
FQL query no longer available. developers.facebook.com/docs/reference/fqlRhinehart
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?Carbajal
I build a library to search for events at a specific location: github.com/tobilg/facebook-events-by-locationByrd
P
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

Prolong answered 23/12, 2015 at 2:16 Comment(2)
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.Fellini
There's not only a Node module, the core module of that service can also be used in JS frontend applications: github.com/tobilg/facebook-events-by-location-coreByrd
L
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.

Luciferin answered 10/4, 2018 at 11:50 Comment(1)
Facebook announced this on April 4th, 2018: developers.facebook.com/blog/post/2018/04/04/…Spectrochemistry
M
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.

Minne answered 7/11, 2018 at 16:21 Comment(0)
D
-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.

Desex answered 6/6, 2014 at 5:26 Comment(1)
Enter "events" where ?Gloaming

© 2022 - 2024 — McMap. All rights reserved.