PHP code example of tzfrs / longurl

1. Go to this page and download the library: Download tzfrs/longurl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tzfrs / longurl example snippets



and = new \tzfrs\LongURL\Endpoints\Expand();
try {
    print $expand->expandURL('https://t.co/XdXRudPXH5'); //https://blog.twitter.com/2013/rich-photo-experience-now-in-embedded-tweets-3
    print $expand->expandURL('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
} catch (\tzfrs\LongURL\Exceptions\ExpandException $e) {
    print $e->getMessage();
}


vices = new \tzfrs\LongURL\Endpoints\Services();
try {
    $services = $services->getServices(); // Object array with all services
} catch (\tzfrs\LongURL\Exceptions\ServicesException $e) {
    print $e->getMessage();
}


vices = new \tzfrs\LongURL\Endpoints\Services();
try {
    $services->isShortURL('https://t.co/XdXRudPXH5'); // True
    $services->isShortURL('https://blog.twitter.com/2013/rich-photo-experience-now-in-embedded-tweets-3'); // False
} catch (\tzfrs\LongURL\Exceptions\ServicesException $e) {
    print $e->getMessage();
}