You can easily create a URL shortener thanks to the service called TinyURL. In this post, we'll create a PHP script that will create a TinyURL from a long URL using their API.
TinyURL is a free service that allows you to create a short URL from a long URL. For example, it can turn:
BASH
https://sabe.io/blog/php-create-tiny-url
into:
BASH
https://tinyurl.com/yyh5vqnv
To interface with their API, we will use the cURL library. We will make a call to their API and get back the short URL.
We've created a PHP script that will create a TinyURL from a long URL using TinyURL's API. Hopefully, you can see how easy it is to create a URL shortener using PHP.