You are here

function shorten_shorten_service in Shorten URLs 7.2

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 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();

  // @TODO: budurl is now a paid shortener service called bl.ink. Consider updating.

  //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_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=';
  }
  $services += array(
    'is.gd' => 'https://is.gd/create.php?format=simple&url=',
    'PeekURL' => 'https://peekurl.com/api.php?desturl=',
    'TinyURL' => 'https://tinyurl.com/api-create.php?url=',
  );
  if (module_exists('shurly')) {
    $services['ShURLy'] = array(
      'custom' => '_shorten_shurly',
    );
  }

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