
How to Dynamically Shorten URLs with TinyURL?
Dzhuneyt Ahmed
Posted · 1 min read
Outdated: While TinyURL’s API may still work, URL shortening services have evolved significantly. Consider using the APIs from Bitly or Short.io for more reliable, feature-rich alternatives.
The URL shortening service TinyURL.com 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("http://tinyurl.com/api-create.php?url=".$url); }
Alternatively, you can use cURL to download remote URLs contents if your server doesn’t support file_get_contents.
