You are here

function messaging_twitter_send_dm in Messaging 6

Same name and namespace in other branches
  1. 6.4 messaging_twitter/messaging_twitter.module \messaging_twitter_send_dm()
  2. 6.2 messaging_twitter/messaging_twitter.module \messaging_twitter_send_dm()
  3. 6.3 messaging_twitter/messaging_twitter.module \messaging_twitter_send_dm()

Send a direct message to Twitter user

1 string reference to 'messaging_twitter_send_dm'
messaging_twitter_messaging in messaging_twitter/messaging_twitter.module
Implementation of hook_messaging

File

messaging_twitter/messaging_twitter.module, line 68
Messaging Twitter sending method

Code

function messaging_twitter_send_dm($destination, $message, $params = array()) {
  _messaging_twitter_include();
  $url = 'http://twitter.com/direct_messages/new.xml';
  $site_username = variable_get('messaging_twitter_username', '');
  $site_password = variable_get('messaging_twitter_password', '');
  $headers = array(
    'Authorization' => 'Basic ' . base64_encode($site_username . ':' . $site_password),
    'Content-type' => 'application/x-www-form-urlencoded',
  );
  $data = 'text=' . urlencode($message->body) . '&user=' . $destination;
  $result = drupal_http_request($url, $headers, 'POST', $data);
}