You are here

function drupagram_fetch_recent_items in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.inc \drupagram_fetch_recent_items()

Fetches a user's recent items.

1 call to drupagram_fetch_recent_items()
drupagram_cron in ./drupagram.module
Implementation hook_cron().

File

./drupagram.inc, line 177
Instagram API functions

Code

function drupagram_fetch_recent_items($id) {
  $params = array();
  $account = drupagram_account_load($id);
  $min_id = db_result(db_query("SELECT MAX(drupagram_id) FROM {drupagram} WHERE username = '%s'", $account->username));
  $params['!min_id'] = (int) $min_id;
  $params['count'] = 6;
  $drupagram = drupagram_connect($account);
  $items = $drupagram
    ->user_recent($id);
  if (empty($items)) {
    return;
  }
  foreach ($items as $media) {
    drupagram_media_save($media);
  }
  db_query("UPDATE {drupagram_account} SET last_refresh=%d WHERE drupagram_id=%d", REQUEST_TIME, $account->id);
}