function twitter_connect in Twitter 7.5
Same name and namespace in other branches
- 6.5 twitter.inc \twitter_connect()
- 6.3 twitter.inc \twitter_connect()
- 6.4 twitter.inc \twitter_connect()
- 7.6 twitter.inc \twitter_connect()
- 7.3 twitter.inc \twitter_connect()
- 7.4 twitter.inc \twitter_connect()
Connect to the Twitter API.
Parameters
object $twitter_account: An authenticated twitter_account object to be used to authenticate against Twitter.
bool $access_global: Whether or not to load the global accounts too.
bool $force: Loads accounts regardless of other access limits. Should be used with care and only for limited scenarios that do would not pose a security risk.
Return value
A Twitter object ready to be used to query the Twitter API or FALSE.
9 calls to twitter_connect()
- drush_twitter_search in ./
twitter.drush.inc - Implements drush_COMMANDFILE_COMMANDNAME()
- twitter_cron in ./
twitter.module - Implements hook_cron().
- 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.
- twitter_non_auth_account_form_submit in ./
twitter.pages.inc - Submit form handler to add a non-authenticated Twitter account.
File
- ./
twitter.inc, line 25
Code
function twitter_connect($twitter_account = NULL, $access_global = FALSE, $force = FALSE) {
// If no account was specified, load the first authenticated account.
if (empty($twitter_account)) {
// Load all authenticated accounts, passing in the same access requirements.
$accounts = twitter_load_authenticated_accounts(NULL, $access_global, $force);
// If no accounts were found, there's a problem.
if (empty($accounts)) {
watchdog('twitter', 'There are no authenticated Twitter accounts to use for API connections.');
}
else {
$twitter_account = reset($accounts);
}
}
if (!empty($twitter_account)) {
$auth = $twitter_account
->get_auth();
if (isset($auth['oauth_token']) && isset($auth['oauth_token_secret'])) {
return new Twitter(variable_get('twitter_consumer_key', ''), variable_get('twitter_consumer_secret', ''), $auth['oauth_token'], $auth['oauth_token_secret']);
}
}
return FALSE;
}