Another straight to the point solutionIn this post I would like to present you a nice URL shortening service that you may use from PHP in a very simple way (perhaps simplest possible!).
Let's say you want to shorten url like this:
To do this you need this simple code:
Now you can echo $new_url to see a new address (which is this case is: http://is .gd/jRqN9).$url = 'http://www.my-website-is-here.com/index.php?subpage'; $new_url = file_get_contents('http://is.gd/api.php?longurl=' . urlencode($url));
Pretty amazing, huh?
Is.Gd announced that they will soon stop using is.gd domain. So the way to shorten addresses will be:
$url = 'http://www.my-website-is-here.com/index.php?subpage';
$new_url = file_get_contents('http://v.gd/create.php?format=simple&url=' . urlencode($url));
Not a big difference, is it? And the resulting address is: http://v. gd/7hCRcu, so it's exactly same length.
As you can notice there is format parameter in the URL above. You can put there "json" or "xml" instead of "simple", but then you will need to decode the output (using json_decode() or simplexml_load_string() ).