title: Facebook graph API loop through paging
body: <p>So I was working with this script to loop through the events from a given page. Suddenly I find it doesn't work anymore :(</p>
  
  <p>I have a feeling it could be a bug, because if you pick any page, view events with an access_token, you can't get any data back for the "next" paginated URL. e.g. try <a href="https://graph.facebook.com/evenightclub/events">https://graph.facebook.com/evenightclub/events</a> in apigee.com</p>
  
  <p>Any ideas?</p>
  
  <p>($fid is the page object id)</p>
  
  <pre><code>    try {
      $facebook = new Facebook(array(
        'appId'  =&gt; '&lt;removed&gt;',
        'secret' =&gt; '&lt;removed&gt;',
      ));
      $access_token = $facebook-&gt;getAccessToken();
  
      $events_data = array();
      $offset = 0;
      $limit = 5000;  
      $params = array('access_token' =&gt; $access_token);
  
      //fetch events from Facebook API
      $data = $facebook-&gt;api("$fid/events/?limit=$limit&amp;offset=$offset", $params);
      $events_data = array_merge($events_data, $data["data"]);
  
      //loop through pages to return all results
      while(in_array("paging", $data) &amp;&amp; array_key_exists("next", $data["paging"])) {
          $offset += $limit;
          $data = $facebook-&gt;api("$fid/events/?limit=$limit&amp;offset=$offset", $params);
          $events_data = array_merge($events_data, $data["data"]);
      }}
  </code></pre>