Generate TinyURLs With 1 Line Of PHP
Reading time: About 0 minutes
All you need is allow_url_fopen enabled in your php.ini and PHP version 4.3.0 or higher. If you don’t know if you have allow_url_fopen enabled, just run the function phpinfo(), which displays all of your PHP settings.
Here’s the 1 line you’ve been waiting for…
$shortenedurl = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI']));What you end up with is a tinyurl.com url of the current page. Sweet, huh? This can be especially important if you have a “Tweet this” link!
61
9 comments skip to comment form
Pliggs said— 6 minutes later
Brenelz said— 9 minutes later
Drew Douglass said— 1 hour later
Rob said— 15 hours later
serj said— 20 hours later
Abhisek said— 6 days later
Brian Cray said— 1 week later
einsteinsboi said— 3 weeks later
James said— 3 months later
Respond to this post—