You are here

function twitter_status_save in Twitter 6.5

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

Saves a TwitterStatus object to {twitter}

2 calls to twitter_status_save()
twitter_fetch_mentions_timeline in ./twitter.inc
Fetches user's mentions of an authenticated account.
twitter_fetch_user_timeline in ./twitter.inc
Fetches a user's timeline.

File

./twitter.inc, line 183

Code

function twitter_status_save($status) {

  // RT's get special handling.
  if (!empty($status->retweeted_status)) {
    $text = 'RT @' . $status->retweeted_status->user->screen_name . ': ' . $status->retweeted_status->text;
  }
  else {
    $text = $status->text;
  }
  $row = array(
    'twitter_id' => $status->id,
    'screen_name' => $status->user->screen_name,
    'created_time' => strtotime($status->created_at),
    'text' => $text,
    'source' => $status->source,
    'in_reply_to_status_id' => $status->in_reply_to_status_id > 0 ? (string) $status->in_reply_to_status_id : NULL,
    'in_reply_to_user_id' => $status->in_reply_to_user_id,
    'in_reply_to_screen_name' => $status->in_reply_to_screen_name,
    'truncated' => (int) $status->truncated,
  );
  if (db_result(db_query("SELECT 1 FROM {twitter} WHERE twitter_id = %s", $row['twitter_id']))) {
    drupal_write_record('twitter', $row, array(
      'twitter_id',
    ));
  }
  else {
    drupal_write_record('twitter', $row);
  }

  // Let other modules know that a status has been saved.
  module_invoke_all('twitter_status_save', $status);
}