You are here

function _twitter_actions_get_twitter_id in Twitter 7.6

Same name and namespace in other branches
  1. 6.5 twitter_actions/twitter_actions.module \_twitter_actions_get_twitter_id()
  2. 7.5 twitter_actions/twitter_actions.module \_twitter_actions_get_twitter_id()

Validates the Twitter account to use to send a Tweet.

If it is a Twitter account, it will check it still exists. If it is [current user], it will see if the current user has an authenticated Twitter account to use.

Parameters

string $screen_name: The selected value that represents a Twitter account to use.

Return value

Integer the Twitter ID of the account to use or NULL.

2 calls to _twitter_actions_get_twitter_id()
twitter_actions_set_status in twitter_actions/twitter_actions.rules.inc
Fetches Twitter account info and submits with the message to the Twitter API.
twitter_actions_set_status_action in twitter_actions/twitter_actions.module
Implementation of a configurable Twitter action. @todo Implementation for language negotiation for the body and sumary. Also need implementation for bodies with multiple values. Right now it is hard coded and it will only get body and summary for…

File

twitter_actions/twitter_actions.module, line 123
Exposes Drupal actions for sending Twitter messages.

Code

function _twitter_actions_get_twitter_id($screen_name) {
  $twitter_uid = NULL;

  // Find out the Twitter ID to use.
  if ($screen_name == '[current user]') {

    // Check if this user has an authenticated account.
    global $user;
    $account = user_load($user->uid);
    foreach ($account->twitter_accounts as $twitter_account) {
      if ($twitter_account
        ->is_auth()) {
        $twitter_uid = $twitter_account->id;
      }
    }
  }
  else {
    module_load_include('inc', 'twitter');
    $twitter_account = twitter_account_load($screen_name);
    if (!empty($twitter_account)) {
      return $twitter_account->twitter_uid;
    }
  }
  return NULL;
}