You are here

function twitter_shorten_url in Twitter 6.2

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

Very lightweight helper function to generate a TinyURL for a given post.

2 calls to twitter_shorten_url()
twitter_actions_set_status_action in twitter_actions/twitter_actions.module
Implementation of a configurable Drupal action. Sends an email.
_twitter_replace_tokens in ./twitter.inc
This function exists because we have an extra-special shorturl token whose value should only be generated if the token is used. This problem goes away in D7's on-demand token system.

File

./twitter.module, line 134

Code

function twitter_shorten_url($url) {
  if (module_exists('shorten')) {
    return shorten_url($url);
  }
  else {
    $response = drupal_http_request("http://tinyurl.com/api-create.php?url=" . $url);
    if ($response->code == 200) {
      return $response->data;
    }
    else {
      return $url;
    }
  }
}