示例#1
0
 public function testCanInstantiateNewPaginationRequest()
 {
     $graphEdge = new GraphEdge($this->request, [], ['paging' => $this->cursorPagination], '/1234567890/likes');
     $nextPage = $graphEdge->getNextPageRequest();
     $prevPage = $graphEdge->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());
 }
示例#2
0
 /**
  * Sends a request to Graph for the next page of results.
  *
  * @param GraphEdge $graphEdge The GraphEdge to paginate over.
  * @param string    $direction The direction of the pagination: next|previous.
  *
  * @return GraphEdge|null
  *
  * @throws FacebookSDKException
  */
 public function getPaginationResults(GraphEdge $graphEdge, $direction)
 {
     $paginationRequest = $graphEdge->getPaginationRequest($direction);
     if (!$paginationRequest) {
         return null;
     }
     $this->lastResponse = $this->client->sendRequest($paginationRequest);
     // Keep the same GraphNode subclass
     $subClassName = $graphEdge->getSubClassName();
     $graphEdge = $this->lastResponse->getGraphEdge($subClassName, false);
     return count($graphEdge) > 0 ? $graphEdge : null;
 }