You are here

private function FacebookFeedBlock::getPosts in Facebook Feed Block 8

Fetches a list of page posts using Facebook's Graph API.

Return value

mixed An array of objects containing post data.

1 call to FacebookFeedBlock::getPosts()
FacebookFeedBlock::build in src/Plugin/Block/FacebookFeedBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/FacebookFeedBlock.php, line 181

Class

FacebookFeedBlock
Provides a 'FacebookFeedBlock' block.

Namespace

Drupal\facebook_feed\Plugin\Block

Code

private function getPosts() {
  $settings = $this
    ->getSettings();
  $uri = 'https://graph.facebook.com/' . $settings['page_id'] . '/' . $settings['feedType'] . '?summary=true&limit=' . $settings['limit'] . '&access_token=' . $settings['access_token'] . '&fields=' . $settings['fields'];
  $response = \Drupal::httpClient()
    ->get($uri, [
    'headers' => [
      'Accept' => 'text/plain',
    ],
  ]);
  return Json::decode($response
    ->getBody());
}