1

I am trying to work out how to get better data from the Facebook Open Graph API as it appears they now support recurring events for profile pages, yet there does not appear to be any way to get that correctly from their API as they return the start date as the first day the event runs on and the end date as the last day it runs on. My first attempt was to simply check if the events start and end on the same day and assume they occur weekly, but as you can see from this Facebook page they actually allow you to set them up to occur on mutiple days at different times! Ie: Sunday 12:00pm and Wednesday at 4:00pm:

https://www.facebook.com/pg/hobbytownewportnews/events

JUL 18:  Micro FPV - Every Tuesday & Saturday (Jun 17 - Dec 16)
JUL 22: Gunpla Build Day - Every Saturday (Jun 17 - Dec 30)
JUL 16: RC Drifting - Every Wednesday & Sunday (Jun 18 - Dec 13)
JUL 20: Pizza & Plastics - Every Thursday (Jun 22 - Dec 28)

I am getting the events using this API:

https://developers.facebook.com/docs/graph-api/reference/page/events/

And here is a sample API call using the API (you will need your own Access Token to execute it however):

https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=hobbytownewportnews%2Fevents%3Ftime_filter%3Dupcoming%26fields%3Did%2Cname%2Cend_time%2Cstart_time&version=v2.9

and below is the response we get back. Now the problem as you can see is the start and end times and there is no data that indicates if the event is recurring and Facebook does nothing to fix them up so they make sense as individual upcoming events. There is more data returned via the API, but the rest of it is just descriptive so I left that out.

{
  "data": [
    {
      "id": "272398049894766",
      "name": "Pizza & Plastics - Every Thursday",
      "end_time": "2017-12-28T20:00:00-0500",
      "start_time": "2017-06-22T16:00:00-0400"
    },
    {
      "id": "334856180266567",
      "name": "RC Drifting - Every Wednesday & Sunday",
      "end_time": "2017-12-13T20:00:00-0500",
      "start_time": "2017-06-18T12:00:00-0400"
    },
    {
      "id": "308995412882009",
      "name": "Gunpla Build Day - Every Saturday",
      "end_time": "2017-12-30T14:00:00-0500",
      "start_time": "2017-06-17T12:00:00-0400"
    },
    {
      "id": "1473270249392907",
      "name": "Micro FPV - Every Tuesday & Saturday",
      "end_time": "2017-12-16T18:00:00-0500",
      "start_time": "2017-06-17T10:00:00-0400"
    }
  ],
}

Any ideas? Is there a different API call to get this stuff? The catch is I can't simply assume any event that spans multiple days is a recurring event because you can also put in events that literally do span multiple days like this one:

https://www.facebook.com/events/1854268061514839

and the response to get that from the Open Graph API returns what you would expect, with the start and end dates spanning the entire set of days and even starting at 8AM and ending at 8PM on the final day.

{
  "data": [
    {
      "id": "1854268061514839",
      "name": "2017 ROAR off road electric 8th and 4wd SCT electric Nationals",
      "end_time": "2017-07-23T20:00:00-0700",
      "start_time": "2017-07-20T08:00:00-0700"
    }
  ],
}

2 Answers 2

2

You can make a Facebook API graph request specifying event_times parameter, querying Facebook page like:

https://graph.facebook.com/v2.10/<pageId>/events?fields=start_time,end_time,event_times

where pageId is a Facebook page id.

Otherwise you can query a single event:

https://graph.facebook.com/v2.10/<eventId>?fields=start_time,end_time,event_times

where eventId is a Facebook event id.

1

"event_times" = Array of times of a multi-instance event

Add this to your list of fields, and then loop around the result.

2
  • This answer would be more useful if it demonstrated how that might be done. As it stands now, it's a bit sparse.
    – Cody Gray
    Commented Sep 22, 2017 at 17:54
  • Thanks! Not sure if I missed this originally or if they added this after my original post, but I am now seeing this data in the return result set. Commented Sep 23, 2017 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.