How to Dynamically Shorten URLs with TinyURL?

The URL shortening service provides an API for programmatically processing URL shortening requests through your own script.

It’s actually pretty easy.

function short($url) {
    return file_get_contents("".$url);

Alternatively, you can use cURL to download remote URLs contents if your server doesn’t support file_get_contents.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.