You are here

function shurly_expand in ShURLy 6

Same name and namespace in other branches
  1. 8 shurly.module \shurly_expand()
  2. 7 shurly.module \shurly_expand()

Function to get the long url.

1 call to shurly_expand()
shurly_service_expand in shurly_service/shurly_service.inc
Callback for shurly/api/shorten

File

./shurly.module, line 447
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function shurly_expand($short, $account = NULL) {
  $error = '';
  $success = FALSE;
  $account = $account ? $account : $GLOBALS['user'];
  $rate_limit = shurly_rate_limit_allowed($account);
  if (!$rate_limit['allowed']) {
    $error = t('Rate limit exceeded. You are limited to @rate requests per @time minute period.', array(
      '@rate' => $rate_limit['rate'],
      '@time' => $rate_limit['time'],
    ));
  }
  elseif ($redirect = shurly_get_redirect($short, TRUE)) {
    $success = TRUE;
    $long_url = $redirect->destination;
  }
  else {
    $error = t('Not found');
  }
  return array(
    'success' => $success,
    'error' => $error,
    'longUrl' => $long_url,
    'shortUrl' => _surl($short, array(
      'absolute' => TRUE,
    )),
    'user' => (int) $account->uid,
  );
}