PHP Class To Interact With API

The URL shortening service is yet another site that converts a long URL into a small one, but differs in that it generally produces smaller URLs than others. The API doesn't require that you create an account on the site, but there are one or two limitations to using the service that you should be aware of first. You can find out these limitations by reading the terms and conditions. You can use this class to interact with, but the service doesn't have a massive amount of features the class only contains shorten() and expand() functions that work exactly as expected. You can download the class using the following link:

Download the API interaction PHP class.

To convert a URL into its equivalent you can call the shorten() function like this.

$isgd = new Isgd();
echo $isgd ->shorten('');

This will return

To convert a URL back to the original equivalent you can call the expand() function like this.

$isgd = new Isgd();
echo $isgd->expand('');

This will return the original URL, or in this case.

The service also has a couple of extra features that allow you to either preview the URL before going to it, or to add some keywords to the URL. The only thing that you should be aware of is that you can't do both of these actions at the same time.

To create a preview URL use the following code.

$isgd = new Isgd();
echo $isgd ->shorten('', true);

This will return, which is's way of moving you to a preview page so that you can see what the link is before clicking on it.

To add some keywords to your URL use the following code. Note that you must use false as the preview parameter if you want to do this. This is because the service can't do both previewing and keywords in the URL and the preview parameter will take precedence over the keyword parameter.

$isgd = new Isgd();
echo $isgd ->shorten('', false, 'hash/bang-code');

This will return the following URL.

Note that the string you pass as the keyword is "slugged" before being used in the URL. This means that only alphanumeric characters are used and any spaces are converted to hyphens. ignores anything after the trailing hyphen so you can include any text you want, it doesn't even have to be the same for different URLs.

Add new comment

The content of this field is kept private and will not be shown publicly.
1 + 15 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.