function shorten_shorten_service in Shorten URLs 8.2
Same name and namespace in other branches
- 8 shorten.module \shorten_shorten_service()
- 6 shorten.module \shorten_shorten_service()
- 7.2 shorten.module \shorten_shorten_service()
- 7 shorten.module \shorten_shorten_service()
Implements hook_shorten_service().
File
- ./
shorten.module, line 197
Code
function shorten_shorten_service() {
$services = [];
if (\Drupal::config('shorten.settings')
->get('shorten_budurl')) {
$services['budurl'] = [
'url' => 'http://budurl.com/api/v1/budurls/shrink?api_key=' . \Drupal::config('shorten.settings')
->get('shorten_budurl') . '&format=txt&long_url=',
];
}
if (\Drupal::config('shorten.settings')
->get('shorten_ez')) {
$services['ez'] = [
'url' => 'http://ez.com/api/v1/ezlinks/shrink?api_key=' . \Drupal::config('shorten.settings')
->get('shorten_ez') . '&format=txt&long_url=',
];
}
if (\Drupal::config('shorten.settings')
->get('shorten_bitly_login') && \Drupal::config('shorten.settings')
->get('shorten_bitly_key')) {
$services['bit.ly'] = 'https://api-ssl.bitly.com/v3/shorten?format=txt&login=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_login') . '&apiKey=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_key') . '&x_login=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_login') . '&x_apiKey=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_key') . '&longUrl=';
$services['j.mp'] = 'https://api-ssl.bitly.com/v3/shorten?format=txt&domain=j.mp&login=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_login') . '&apiKey=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_key') . '&x_login=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_login') . '&x_apiKey=' . \Drupal::config('shorten.settings')
->get('shorten_bitly_key') . '&longUrl=';
}
if (\Drupal::config('shorten.settings')
->get('shorten_googl')) {
$services['goo.gl'] = [
'custom' => '_shorten_googl',
];
}
$services += [
'is.gd' => 'https://is.gd/create.php?format=simple&url=',
'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 (\Drupal::config('shorten.settings')
->get('shorten_fwd4me')) {
$services['fwd4.me'] = 'http://api.fwd4.me/?key=' . \Drupal::config('shorten.settings')
->get('shorten_fwd4me') . '&url=';
}
if (\Drupal::moduleHandler()
->moduleExists('shurly')) {
$services['ShURLy'] = [
'custom' => '_shorten_shurly',
];
}
// Alphabetize. ksort() is case-sensitive.
uksort($services, 'strcasecmp');
return $services;
}