Created
March 26, 2010 19:39
-
-
Save fishy/345292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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