You are here

function twitter_user_save in Twitter 6.2

2 calls to twitter_user_save()
twitter_account_list_form_submit in ./twitter.pages.inc
twitter_add_account_submit in ./twitter.pages.inc

File

./twitter.inc, line 439
A wrapper API for the Twitter microblogging service.

Code

function twitter_user_save($account = array(), $force_import = FALSE) {
  $account += array(
    'screen_name' => '',
    'import' => 1,
  );
  if (db_result(db_query("SELECT 1 FROM {twitter_user} WHERE uid = %d AND screen_name = '%s'", $account['uid'], $account['screen_name']))) {
    drupal_write_record('twitter_user', $account, array(
      'uid',
      'screen_name',
    ));
  }
  else {
    drupal_write_record('twitter_user', $account);
  }
  if ($force_import && $account['import']) {
    if (empty($account['protected']) || empty($account['password'])) {
      $statuses = twitter_fetch_timeline($account['screen_name']);
    }
    else {
      twitter_fetch_account_info($account['screen_name'], $account['password']);
      $statuses = twitter_fetch_statuses($account['screen_name'], $account['password']);
    }
    if (!empty($statuses)) {
      twitter_cache_account($statuses[0]['account']);
      twitter_touch_account($account['screen_name']);
    }
  }
}