You are here

function twitter_set_status in Twitter 6.2

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

Post a message to a Twitter.com account.

Parameters

$screen_name: The screen name of a Twitter.com user.

$password: The password of a Twitter.com user.

$text: The text to post. Strings longer than 140 characters will be truncated by Twitter.

$source: A string indicating the program or site used to post the message. Source strings should be registered with Twitter, as unrecgonized sources are ignored.

Return value

The full results of the Drupal HTTP request, including the HTTP response code returned by Twitter.com.

2 calls to twitter_set_status()
twitter_actions_set_status_action in twitter_actions/twitter_actions.module
Implementation of a configurable Drupal action. Sends an email.
twitter_nodeapi in ./twitter.module
Implementation of hook_nodeapi().

File

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

Code

function twitter_set_status($screen_name, $password, $text, $source = 'drupal') {
  $url = "http://" . variable_get('twitter_api_url', 'twitter.com') . "/statuses/update.xml";
  $headers = array(
    'Authorization' => 'Basic ' . base64_encode($screen_name . ':' . $password),
    'Content-type' => 'application/x-www-form-urlencoded',
  );
  $data = 'status=' . urlencode($text);
  if (!empty($source) && variable_get('twitter_set_source', TRUE)) {
    $data .= "&source=" . urlencode($source);
  }
  return drupal_http_request($url, $headers, 'POST', $data);
}