Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search for public events by location using the Facebook Graph API

Help! I'm trying to search for public events by location using the Facebook Graph API. I've seen many posts saying that this is not possible with the current version of the Graph API out now or FQL. But, I do see sites with this feature as well as many FQL workarounds. None have been successful for me.

Here are my search parameters being requested from the API

/search?q=*&type=event&center=10.4434041,-61.419835&distance=1000

It was my hope that this would be the answer, simply because it seems to cover the type event and specific location. But, I was wrong and I get a list of the same marketing event for a free samsung galaxy 20 years into the future in 30 different languages.

So I thought to query for the venue(place) in that specific location, which turned out successful, and then grab the id's from those venues and query each id one by one to see if there are any associated events to that specific venue. I don't know how to go about the second half of the query with the results of the first search query but this is what I have so far.

/search?type=place&q=*&center=10.4434041%2C-61.419835&distance=1000&fields=name,id

Returns

{
  "data": [
  {
    "name": "Valid Venue!",
    "id": "740199068928858"
  },
  {
    "name": "Valid Venue!",
    "id": "522158807878843"
  },
  {
    more valid venue data!!
  }
}

I should also note that this venue search will give me all listed places in that location, which, I know is VERY bad and completely inefficient but I'm all out of ideas.

I'm not sure if this is the right path to go down but it seems like the most plausible solution I can think of to get events by location. Any guidance or at all would be greatly appreciated!!

Thanks!!

like image 699
Nigel Earle Avatar asked Aug 26 '15 09:08

Nigel Earle


People also ask

How do I filter Facebook events by location?

Tap Today, Tomorrow, or This Weekend to filter the events that show up in the search results. You can also change the location so you can look for events in other cities by tapping "Nearby" and changing the location before returning to the previous screen. You'll see events in that area for the day you chose.

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

Is Facebook Graph API a REST API?

The Legacy REST API is in the process of being deprecated, while the Graph API is the most current, so if you're unsure of which one to use, your best bet is to go with that one. As you suggested, the Graph API, just like the Legacy REST API, is in fact a RESTful API.


1 Answers

This used to work (or still works until August 7th 2016 if you have a v2.0 app, and the event was create by a page with a location/venue set) as described in

  • Facebook Graph API Get All Events For Latitude and Longitude

for example. With the Graph API itself, it is not possible to search for nearby events in one query.

What you could do is

  1. Search for nearby places
  2. Query each place found by 1. for events

Keep in mind that you'll have to filter yourself regarding passed events etc. It's very inefficient unfortunately...

EDIT 2017-12-20

You can use https://github.com/tobilg/facebook-events-by-location-core for this use case.

like image 114
Tobi Avatar answered Sep 24 '22 23:09

Tobi