PHP code example of tobymaxham / url-shortener

1. Go to this page and download the library: Download tobymaxham/url-shortener 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/ */

    

tobymaxham / url-shortener example snippets


$url = Shortener::short('https://example.com');

$shortener = new TobyMaxham\Ux9\Shortener($url = null, $config = null, $format = 'json');

// set the API Token
$shortener->setToken('YOUR_API_TOKEN');

$shortener->out();

$shortener->short('http://maxham.de');
$shortener->short('http://github.com');

// default = json, alternativ plain, array
$shortener->format($format);
$shortener->out($format);
$shortener->add($url);

$config = [
    'API_TOKEN' => 'YOUR_API_TOKEN',
    'FORMAT' => 'plain',
];

$shortener = new TobyMaxham\Ux9\Shortener($url = null, $config);