function twitter_actions_tweet in Twitter 7.6
Submits a tweet and processes the response.
Either sets a message with the link to the tweet or registers the returned error.
Parameters
object $twitter_account: The TwitterUser object referencing a Twitter.com account.
string $message: The message to post to Twitter.
2 calls to twitter_actions_tweet()
- 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 274 - Exposes Drupal actions for sending Twitter messages.
Code
function twitter_actions_tweet($twitter_account, $message) {
module_load_include('inc', 'twitter');
try {
$status = twitter_set_status($twitter_account, $message);
if ($status) {
drupal_set_message(t('Successfully posted to Twitter: <a href="@status" target="_blank">@status</a>', array(
'@status' => _twitter_status_url($status),
)));
}
} catch (TwitterException $e) {
drupal_set_message(t('An error occurred when posting to Twitter: @message', array(
'@message' => $e
->getMessage(),
)), 'warning');
}
}