You are here

function twitter_fetch_user_timeline in Twitter 6.3

Same name and namespace in other branches
  1. 6.5 twitter.inc \twitter_fetch_user_timeline()
  2. 6.4 twitter.inc \twitter_fetch_user_timeline()
  3. 7.6 twitter.inc \twitter_fetch_user_timeline()
  4. 7.3 twitter.inc \twitter_fetch_user_timeline()
  5. 7.4 twitter.inc \twitter_fetch_user_timeline()
  6. 7.5 twitter.inc \twitter_fetch_user_timeline()

Fetches a user's timeline

1 call to twitter_fetch_user_timeline()
twitter_cron in ./twitter.module
Implementation of hook_cron()

File

./twitter.inc, line 87

Code

function twitter_fetch_user_timeline($id) {
  $account = twitter_account_load($id);
  $since = db_result(db_query("SELECT MAX(twitter_id) FROM {twitter} WHERE screen_name = '%s'", $account->screen_name));
  $twitter = twitter_connect($account);
  $params = array();
  if ($since) {
    $params['since_id'] = $since;
  }
  if ($account->include_retweets) {
    $params['include_rts'] = true;
  }
  if (get_class($twitter) == 'TwitterOAuth') {
    $use_oauth = TRUE;
  }
  else {
    $use_oauth = FALSE;
  }
  $statuses = $twitter
    ->user_timeline($account->id, $params, $use_oauth);
  foreach ($statuses as $status) {
    twitter_status_save($status);
  }
  if (count($statuses) > 0) {
    twitter_account_save($statuses[0]->user);
  }
  db_query("UPDATE {twitter_account} SET last_refresh = %d WHERE twitter_uid=%d", time(), $account->id);
}