Welcome!

My name is Manmohanjit Singh and I’m 15 this year. Sorry you’ll just have to accept it, I may be a kid to you but trust me I’m not. I live in Malaysia and I go to school at SMK USJ 12. Read more...

Twitter

  • Loading...

@manmohanjit

Recent Tracks

  • Loading...

manmohanjit1

# Using is.gd's API to shorten URL's

by Manmohanjit Singh on Feb 19th, 2010 in Code.

After posting on how to automatically shorten URLs with TinyURL using its API which provided extra long URLs, I discovered is.gd. Its another URL shortening service. The URLs will be 18 characters or less, including the beginning http://.

We will create a simple function, and in that we will use the file_get_contents() function which gets the data in a web page.

If you go to: http://is.gd/api.php?longurl=http://manmohanjit.com and view its source, it inputs the shortened URL right on the page with no Doctype clarification, so you just need to use the file_get_contents() PHP function to fetch the data on that page and input it on your page.

	function isGD_URL($url) {
	$isgd = file_get_contents('http://is.gd/api.php?longurl='.$url);
	return $isgd;
}

Now you can choose either to use TinyURL or is.gd to shorten your URLs.

Tags:

No comments

  • No comments yet...

Leave A Comment

I'm watching you, please be nice and try not to spam. Comments are moderated. You can paste links directly, it will be formatted automatically. Basic XHTML tags are allowed.

Oh, I almost forgot. Comments are powered by Ajax, so don't hit the submit button twice. Thanks!

Wait for 15 seconds...