You are here

public function SocialContentVK::getRows in Social Content 7.2

Get the rows to import.

Parameters

mixed $last_id: The id of the last import.

Return value

mixed

Overrides SocialContent::getRows

File

modules/vk/social_content_vk.class.inc, line 116
Social Content VK class.

Class

SocialContentVK
@file Social Content VK class.

Code

public function getRows($last_id = NULL) {
  $settings = array_merge($this->settings['global'], $this->settings['instance']);
  if (!empty($settings['owner_id'])) {
    $params = array(
      'owner_id' => $settings['owner_id'],
      'photo_sizes' => 1,
    );
    if (!empty($settings['limit'])) {
      $params['count'] = $settings['limit'];
    }
    if (!empty($settings['api_version'])) {
      $params['v'] = $settings['api_version'];
    }
    $url = $settings['api_url'] . '/method/wall.get';
    $result = $this
      ->httpRequest(url($url, array(
      'query' => $params,
      'external' => TRUE,
    )));
    if ($result->code == 200) {
      $response = json_decode($result->data);
      if (!isset($response->error)) {
        return $response->response->items;
      }
      else {
        watchdog('social_content_vk', 'Error fetching feed, data: %data', array(
          '%data' => $response->error->error_msg,
        ), WATCHDOG_WARNING);
      }
    }
  }
  return FALSE;
}