Skip to content

Instantly share code, notes, and snippets.

@fishy
Created March 26, 2010 19:39
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 fishy/345292 to your computer and use it in GitHub Desktop.
Save fishy/345292 to your computer and use it in GitHub Desktop.
<?php
$shorten_prefix = "http://is.gd/api.php?longurl=";
$keyword = "longUrl";
echo ' { "results": {';
$params = explode('&', $_SERVER['QUERY_STRING']);
$first = true;
foreach($params as $param) {
if(preg_match("/^$keyword=(.*)/", $param, $match)) {
$url = $match[1];
if($first)
$first = false;
else
echo ',';
echo ' "'.urldecode($url).'": { "shortUrl": "';
echo file_get_contents($shorten_prefix.$url);
echo '" }';
}
}
echo ' } }';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment