| 1 |
<?php |
<?php |
| 2 |
// $Id: twitter.inc,v 1.3.2.10 2009/06/20 16:29:14 eaton Exp $ |
// $Id: twitter.inc,v 1.3.2.11 2009/07/02 13:23:44 eaton Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 141 |
return drupal_http_request($url, $headers, 'POST', $data); |
return drupal_http_request($url, $headers, 'POST', $data); |
| 142 |
} |
} |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
/** |
| 146 |
|
* Send a direct message to another Twitter user. |
| 147 |
|
* |
| 148 |
|
* @param $screen_name |
| 149 |
|
* The screen name of a Twitter.com user. |
| 150 |
|
* @param $password |
| 151 |
|
* The password of a Twitter.com user. |
| 152 |
|
* @param $to |
| 153 |
|
* The ID or screen name of the recipient user. |
| 154 |
|
* @param $text |
| 155 |
|
* The text to post. Strings longer than 140 characters will be truncated by |
| 156 |
|
* Twitter. |
| 157 |
|
* @return |
| 158 |
|
* The full results of the Drupal HTTP request, including the HTTP response |
| 159 |
|
* code returned by Twitter.com. |
| 160 |
|
*/ |
| 161 |
|
function twitter_send_dm($screen_name, $password, $to, $text) { |
| 162 |
|
$url = "http://" . variable_get('twitter_api_url', 'twitter.com') . "/direct_messages/new.xml"; |
| 163 |
|
|
| 164 |
|
$headers = array('Authorization' => 'Basic '. base64_encode($screen_name .':'. $password), |
| 165 |
|
'Content-type' => 'application/x-www-form-urlencoded'); |
| 166 |
|
$data = 'text='. urlencode($text); |
| 167 |
|
$data .= '&user='.$to; |
| 168 |
|
|
| 169 |
|
return drupal_http_request($url, $headers, 'POST', $data); |
| 170 |
|
} |
| 171 |
|
|
| 172 |
|
|
| 173 |
/** |
/** |
| 174 |
* Fetch the full information for a Twitter.com account. |
* Fetch the full information for a Twitter.com account. |
| 175 |
* |
* |