You are here

public function SocialContentFacebook::getRows in Social Content 7.2

Get the rows to import.

Parameters

mixed $last_id: The id of the last import.

Return value

bool|object The data object, or FALSE on error.

Overrides SocialContent::getRows

File

modules/facebook/social_content_facebook.class.inc, line 167
Social Content Facebook class.

Class

SocialContentFacebook
@file Social Content Facebook class.

Code

public function getRows($last_id = NULL) {
  $settings = $this->settings['instance'];
  $global_settings = $this->settings['global'];
  $params = array(
    'access_token' => $global_settings['access_token'],
    'fields' => 'message,id,created_time,from,full_picture',
  );
  if (!empty($settings['limit'])) {
    $params['limit'] = $settings['limit'];
  }
  $url = url($global_settings['graph_url'] . '/' . $settings['account'] . '/posts', array(
    'query' => $params,
    'external' => TRUE,
  ));
  $result = $this
    ->httpRequest($url);
  if ($result->code == 200) {
    $posts = json_decode($result->data);
    return $posts->data;
  }
  else {
    watchdog('social_content_facebook', 'Error fetching feed, data: %data', array(
      '%data' => $result->data,
    ), WATCHDOG_WARNING);
    return FALSE;
  }
}