15 $url =
'https://graph.facebook.com/v8.0/';
16 $url .= $params[
'endpoint'];
18 $clientParameters = is_array($params[
'fields']) ? $params[
'fields'] : array();
19 $clientParameters = $clientParameters + array(
'access_token' => $this->adapter->getToken());
22 if ($params[
'method'] ==
'GET')
24 $url .=
'?' . http_build_query($clientParameters,
"",
"&");
25 $result = $this->client->get($url);
27 elseif ($params[
'method'] ==
'DELETE')
29 $result = $this->client->delete($url, $clientParameters,
true);
33 $result = $this->client->post($url, $clientParameters,
true);
35 if (!$params[
'has_pagination'])
40 $partialResult = $result;
45 $decodedResult = Json::decode($partialResult);
46 $nextPage = ($decodedResult[
'paging'] && $decodedResult[
'paging'][
'next']) ? $decodedResult[
'paging'][
'next'] :
false;
47 unset($decodedResult[
'paging']);
49 $result = array_merge_recursive($result, $decodedResult);
53 $this->client->query($params[
'method'], $nextPage);
54 $partialResult = $this->client->getResult();
61 return $partialResult;
66 while($nextPage && $page < 20);
68 return Json::encode($result);