Exemplo n.º 1
0
 public function testCanInstantiateNewPaginationRequest()
 {
     $graphList = new GraphList($this->request, [], ['paging' => $this->cursorPagination], '/1234567890/likes');
     $nextPage = $graphList->getNextPageRequest();
     $prevPage = $graphList->getPreviousPageRequest();
     $this->assertInstanceOf('Facebook\\FacebookRequest', $nextPage);
     $this->assertInstanceOf('Facebook\\FacebookRequest', $prevPage);
     $this->assertNotSame($this->request, $nextPage);
     $this->assertNotSame($this->request, $prevPage);
     $this->assertEquals('/v1337/1234567890/likes?access_token=foo_token&after=bar_after_cursor&appsecret_proof=857d5f035a894f16b4180f19966e055cdeab92d4d53017b13dccd6d43b6497af&foo=bar&keep=me', $nextPage->getUrl());
     $this->assertEquals('/v1337/1234567890/likes?access_token=foo_token&appsecret_proof=857d5f035a894f16b4180f19966e055cdeab92d4d53017b13dccd6d43b6497af&before=bar_before_cursor&foo=bar&keep=me', $prevPage->getUrl());
 }
Exemplo n.º 2
0
 /**
  * Sends a request to Graph for the next page of results.
  *
  * @param GraphList $graphList The GraphList to paginate over.
  * @param string    $direction The direction of the pagination: next|previous.
  *
  * @return GraphList|null
  *
  * @throws FacebookSDKException
  */
 public function getPaginationResults(GraphList $graphList, $direction)
 {
     $paginationRequest = $graphList->getPaginationRequest($direction);
     if (!$paginationRequest) {
         return null;
     }
     $this->lastResponse = $this->client->sendRequest($paginationRequest);
     // Keep the same GraphObject subclass
     $subClassName = $graphList->getSubClassName();
     $graphList = $this->lastResponse->getGraphList($subClassName, false);
     return count($graphList) > 0 ? $graphList : null;
 }