List of all facebook events in a given location in the last two years

谁说胖子不能爱 提交于 2019-12-06 04:23:41

问题


What I am trying to do

I am trying to extract a list of all public facebook events that have happened in a given city in 2012 and 2013. Furthermore for each of them, I want to extract the following:

  • event name
  • event description
  • date
  • location
  • number of people on attending/maybe/declined

What I have tried so far

I have been trying the following query in graph explorer

search?q={Oslo}& [type={event}](#searchtypes)

I have ignored the date range constraint for now. I figure that I can fix that later.

The problem

This is listing status updates (stories), places and everything else, and returning it as JSON objects. However, this won't provide with me with all the data fields that I require. Any ideas?

Sidenote

I have tried looking into FQL but apparently that cannot do a search like this? (If it can, feel free to help out). The closest I got was this:

SELECT eid FROM event_member WHERE uid IN 
(SELECT page_id FROM place WHERE  
 distance(latitude, longitude, "37.76", "-122.427") < 1000)

But this only gives me events in the future. Maybe if it allowed me to look in the past too?


回答1:


Looks like FQL can give you the desired result. This FQL (which is extension to what you started) will show you all events between 2012 and 2013 with the data about the event you wanted:

select 
    eid, 
    name, 
    description, 
    location, 
    all_members_count, 
    attending_count, 
    unsure_count, 
    not_replied_count, 
    declined_count, 
    start_time, 
    end_time,
    venue 
from 
    event 
where     
    eid in 
    (
        select 
            eid, 
            start_time 
        from 
            event_member 
        where 
            uid in 
            (
                select 
                    page_id 
                from 
                    place 
                where 
                    distance(latitude, longitude, "37.76", "-122.427") < 1000
            ) and 
            start_time > "2012-01-01"
    ) and 
    end_time < "2013-01-01" and 
    end_time <> 'null' 

And this how one of the results I got for running this query:

{
  "eid": 170775033066718, 
  "name": "Lavender Diamond at The Chapel - Dec 11", 
  "description": "Get tickets: http://ticketf.ly/SUb4w9\nDetails: http://www.thechapelsf.com/event/184715/\n\nVERY SPECIAL GUEST WILL BE ANNOUNCED DAY OF SHOW", 
  "location": "The Chapel", 
  "all_members_count": 92, 
  "attending_count": 30, 
  "unsure_count": 3, 
  "not_replied_count": 59, 
  "declined_count": 4, 
  "start_time": "2012-12-11T20:00:00", 
  "end_time": "2012-12-12T00:00:00", 
  "venue": {
    "street": "", 
    "city": "", 
    "state": "", 
    "country": "", 
    "latitude": 37.760503799154, 
    "longitude": -122.42123452518, 
    "id": 113634312122520
  }
}



回答2:


Searching through public objects which you aren't linked to in any way (no participation, no invitation) can only be done through the Graph Search API, not with the Graph API nor FQL.

Currently, this is the only documentation for Graph Search. You will see that this API doesn't offer much possibilities, so if you want to achieve your goal, you will have to cobble something together. There is not any direct way to do this.

If we gather what is being told about events, this is pretty much everything we have:

Search Types

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

Fields

You can restrict the fields returned by these searches using the ?fields= URL parameter, in the same way you can when reading other objects. For example, to get only the names of events, you can do the following:

Event Names: https://graph.facebook.com/search?fields=name&q=conference&type=event

Time

When searching for public posts or posts on the user's News Feed, you can page over the results by using the since, until and limit parameters. since and until both accept a unix timestamp. When paging back in time, you should use until in conjunction with limit where until is the unixtime value of the created_time field in the last object returned by your previous query. When paging forward in time you should set since to be the unixtime value of the created_time field in the first object returned by your previous query. Please note, you can only search about 1 to 2 weeks back in the News Feed.

The next thing to know is that the result set is composed of the events for which one of their fields contains the string you are looking for (q=Oslo). So, "Oslo" may appear in either the message, in the description, by luck in the location field and by misfortune in the timezone field.

You will then have to filter out the results "manually". You might just search for events containing "Oslo" and then check if the location indeed contains "Oslo. Or if you easily want to find events with a specific location, I advice you to search for strings formatted as "City, Country", because this is how Facebook format cities. So you might just do:

search?fields=location&q="Oslo, Norway"&type=event&since=1356994800

Where 1356994800 is the unixtime since then you want to retrieve events.

Possible result:

{
  "data": [
    {
      "location": "Oslo, Norway", 
      "id": "211893915563330", 
      "start_time": "2022-02-08T00:00:00"
    }, 
    {
      "location": "Lillestrøm, Norway", 
      "id": "641379122561097", 
      "start_time": "2015-09-06T09:00:00+0200"
    }, 
    {
      "location": "Oslo, Norway", 
      "id": "1434492323451716", 
      "start_time": "2014-11-06T20:45:00+0100"
    }, 
    {
      "location": "Oslo, Norway", 
      "id": "563423357073321", 
      "start_time": "2014-09-20"
    }, 

    ...

    {
      "location": "Oslo, Norway", 
      "id": "628230923890648", 
      "start_time": "2013-01-16T19:00:00+0100"
    }
  ],
}

Then, perhaps use the Google Maps API to find out if the found locations are indeed close to Oslo. I.e. "Lillestrøm, Norway" is quite close from it.



来源:https://stackoverflow.com/questions/21286441/list-of-all-facebook-events-in-a-given-location-in-the-last-two-years

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!