tzfrs / urlextender
This library extends short URLs to longURLs using HTTP-Header Location
0.0.2.1
2015-09-10 14:25 UTC
Requires
- gilbitron/php-simplecache: ^1.4
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2024-11-13 12:08:44 UTC
README
This library can be used to expand short URLs such as https://t.co/XdXRudPXH5 and get the URL that is behind the short URL using Guzzles head method and reading the Location header
Install
Install via composer:
{ "require": { "tzfrs/urlextender": "0.0.2.1" } }
Run composer install
or composer update
.
Getting Started
Note: You can also see the examples.php for more examples.
Basic parsing
<?php require __DIR__ . '/vendor/autoload.php'; $urlExtender = new \tzfrs\URLExtender\URLExtender(); try { print $urlExtender->extendURL('https://t.co/XdXRudPXH5'); // https://blog.twitter.com/2013/rich-photo-experience-now-in-embedded-tweets-3 print $urlExtender->extendURL('https://blog.twitter.com/2013/rich-photo-experience-now-in-embedded-tweets-3'); //https://blog.twitter.com/2013/rich-photo-experience-now-in-embedded-tweets-3 print $urlExtender->extendURL('http://httpstat.us/404'); // URLExtenderException (404) print $urlExtender->extendURL('http://httpstat.us/500'); // URLExtenderException (500) } catch (\tzfrs\URLExtender\Exceptions\URLExtenderException $e) { print $e->getCode() . ': ' . $e->getMessage(); }