title: Decoding recurring events from Facebook Open Graph API?
body: <p>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:</p>
  
  <p><a href="https://www.facebook.com/pg/hobbytownewportnews/events" rel="nofollow noreferrer">https://www.facebook.com/pg/hobbytownewportnews/events</a></p>
  
  <pre><code>JUL 18:  Micro FPV - Every Tuesday &amp; Saturday (Jun 17 - Dec 16)
  JUL 22: Gunpla Build Day - Every Saturday (Jun 17 - Dec 30)
  JUL 16: RC Drifting - Every Wednesday &amp; Sunday (Jun 18 - Dec 13)
  JUL 20: Pizza &amp; Plastics - Every Thursday (Jun 22 - Dec 28)
  </code></pre>
  
  <p>I am getting the events using this API:</p>
  
  <p><a href="https://developers.facebook.com/docs/graph-api/reference/page/events/" rel="nofollow noreferrer">https://developers.facebook.com/docs/graph-api/reference/page/events/</a></p>
  
  <p>And here is a sample API call using the API (you will need your own Access Token to execute it however):</p>
  
  <p><a href="https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&amp;path=hobbytownewportnews%2Fevents%3Ftime_filter%3Dupcoming%26fields%3Did%2Cname%2Cend_time%2Cstart_time&amp;version=v2.9" rel="nofollow noreferrer">https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&amp;path=hobbytownewportnews%2Fevents%3Ftime_filter%3Dupcoming%26fields%3Did%2Cname%2Cend_time%2Cstart_time&amp;version=v2.9</a></p>
  
  <p>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.</p>
  
  <pre><code>{
    "data": [
      {
        "id": "272398049894766",
        "name": "Pizza &amp; 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 &amp; 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 &amp; Saturday",
        "end_time": "2017-12-16T18:00:00-0500",
        "start_time": "2017-06-17T10:00:00-0400"
      }
    ],
  }
  </code></pre>
  
  <p>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:</p>
  
  <p><a href="https://www.facebook.com/events/1854268061514839" rel="nofollow noreferrer">https://www.facebook.com/events/1854268061514839</a></p>
  
  <p>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.</p>
  
  <pre><code>{
    "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"
      }
    ],
  }
  </code></pre>