You are here

function shorten_shorten_service in Shorten URLs 7

Same name and namespace in other branches
  1. 8.2 shorten.module \shorten_shorten_service()
  2. 8 shorten.module \shorten_shorten_service()
  3. 6 shorten.module \shorten_shorten_service()
  4. 7.2 shorten.module \shorten_shorten_service()

Implements hook_shorten_service().

File

./shorten.module, line 258
Shortens URLs via external services.

Code

function shorten_shorten_service() {
  $services = array();
  if (variable_get('shorten_budurl', '')) {
    $services['budurl'] = array(
      'url' => 'http://budurl.com/api/v1/budurls/shrink?api_key=' . variable_get('shorten_budurl', '') . '&format=txt&long_url=',
    );
  }
  if (variable_get('shorten_ez', '')) {
    $services['ez'] = array(
      'url' => 'http://ez.com/api/v1/ezlinks/shrink?api_key=' . variable_get('shorten_ez', '') . '&format=txt&long_url=',
    );
  }
  if (variable_get('shorten_bitly_login', '') && variable_get('shorten_bitly_key', '')) {
    $services['bit.ly'] = 'https://api-ssl.bitly.com/v3/shorten?format=txt&login=' . variable_get('shorten_bitly_login', '') . '&apiKey=' . variable_get('shorten_bitly_key', '') . '&x_login=' . variable_get('shorten_bitly_login', '') . '&x_apiKey=' . variable_get('shorten_bitly_key', '') . '&longUrl=';
    $services['j.mp'] = 'https://api-ssl.bitly.com/v3/shorten?format=txt&domain=j.mp&login=' . variable_get('shorten_bitly_login', '') . '&apiKey=' . variable_get('shorten_bitly_key', '') . '&x_login=' . variable_get('shorten_bitly_login', '') . '&x_apiKey=' . variable_get('shorten_bitly_key', '') . '&longUrl=';
  }
  if (variable_get('shorten_googl', '')) {
    $services['goo.gl'] = array(
      'custom' => '_shorten_googl',
    );
  }
  $services += array(
    'is.gd' => 'http://is.gd/api.php?longurl=',
    'migre.me' => 'http://migre.me/api.txt?url=',
    'Metamark' => 'http://metamark.net/api/rest/simple?long_url=',
    'PeekURL' => 'http://peekurl.com/api.php?desturl=',
    'qr.cx' => 'http://qr.cx/api/?longurl=',
    'ri.ms' => 'http://ri.ms/api-create.php?url=',
    'TinyURL' => 'http://tinyurl.com/api-create.php?url=',
  );
  if (variable_get('shorten_fwd4me', '')) {
    $services['fwd4.me'] = 'http://api.fwd4.me/?key=' . variable_get('shorten_fwd4me', '') . '&url=';
  }
  if (module_exists('shurly')) {
    $services['ShURLy'] = array(
      'custom' => '_shorten_shurly',
    );
  }

  // Alphabetize. ksort() is case-sensitive.
  uksort($services, 'strcasecmp');
  return $services;
}