Index: twitter.module =================================================================== RCS file: /cvs/drupal/contributions/modules/twitter/twitter.module,v retrieving revision 1.1 diff -u -r1.1 twitter.module --- twitter.module 23 Jan 2007 17:05:50 -0000 1.1 +++ twitter.module 11 Apr 2008 14:42:12 -0000 @@ -25,6 +25,11 @@ '#title' => t('Text format'), '#default_value' => $edit['twitter_text'], '#description' => t('Format of the text to submit. Use !title and !url for the post title and url respectively.')); + $form['twitter']['twitter_use_tinyurl'] = array( + '#type' => 'checkbox', + '#title' => t('Use tinyurls?'), + '#default_value' => $edit['twitter_usetinyurl'], + '#description' => t('Help keep links posts with long paths short')); return $form; case 'insert': case 'update': @@ -55,9 +60,18 @@ } $text = ($account->twitter_text) ? $account->twitter_text : 'New post: !title (!url)'; - $text = t($text, array('!title' => $node->title, - '!url' => url('node/' . $node->nid, NULL, NULL, TRUE))); + $link_to_url = url('node/' . $node->nid, NULL, NULL, TRUE); + if ($account->twitter_use_tinyurl) { + $headers = array('Content-type' => 'application/x-www-form-urlencoded'); + $tiny_urled = drupal_http_request('http://tinyurl.com/api-create.php?url='.urlencode($link_to_url), $headers, 'POST', NULL); + if ($tiny_urled->code==200) { + $link_to_url = $tiny_urled->data; + } + } + + $text = t($text, array('!title' => $node->title, + '!url' => $link_to_url)); $headers = array('Authorization' => 'Basic '. $account->twitter_encrypted, 'Content-type' => 'application/x-www-form-urlencoded'); $data = 'status='. urlencode($text);