You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get Next and Previous should not use cursors (#623)
Summary:
https://developers.facebook.com/docs/graph-api/results/
- next : The Graph API endpoint that will return the next page of data. If not included, this is the last page of data. Due to how pagination works with visibility and privacy, it is possible that a page may be empty but contain a next paging link. Stop paging when the next link no longer appears.
- previous : The Graph API endpoint that will return the previous page of data. If not included, this is the first page of data.
===
For example: If my cursor has total 4 items (default limit is 25)
```
$cursor->setDefaultUseImplicitFetch(true);
foreach ($cursor as $item) {
$data[] = $item->exportAllData();
}
```
So I need to make one request to get the cursor with 4 items. The current code **getNext()** will always return a URL and
```
public function fetchAfter() {
$request = $this->createAfterRequest();
if (!$request) {
return;
}
$this->appendResponse($request->execute());
}
```
**fetchAfter()** will **execute** one more request and return an empty data. So, we need to make 2 requests to get for only 4 items.
So if **$content['paging']['next']** is empty, we should return null and do not need to make more requests
Pull Request resolved: #623
Reviewed By: satwikareddy3
Differential Revision: D67995304
Pulled By: stcheng
fbshipit-source-id: 78e3cc4167e10f228e7a3c4e572c39b87634c602
0 commit comments