Skip to content

Instantly share code, notes, and snippets.

@dtinth
Created August 15, 2010 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtinth/525516 to your computer and use it in GitHub Desktop.
Save dtinth/525516 to your computer and use it in GitHub Desktop.
<?php
$q = $_SERVER['QUERY_STRING'];
$o = array();
if (preg_match_all('~longUrl=([^&]+)~', $q, $m)) {
foreach ($m[1] as $v) {
$url = urldecode($v);
if (substr($url, 0, 14) != 'http://lnw.me/' && !isset($o[$url])) {
$o[$url] = array(
'shortUrl' => file_get_contents('http://lnw.me/s/short.php?url='
);
}
}
}
echo $_GET['callback'] . '(';
echo json_encode(array(
'results' => $o
));
echo ');';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment