PHP code example of expirenza / shorturl-helper

1. Go to this page and download the library: Download expirenza/shorturl-helper 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/ */

    

expirenza / shorturl-helper example snippets

code
 

use Expirenza\short\Link;

$class = new Link('some token', 'https://server.url');
$result = $class->getOne('https://google.com');

// output
var_dump($result);
code
 

use Expirenza\short\Link;

$class = new Link('some token', 'https://server.url');
$result = $class->getMany(['https://google.com', 'https://mail.com']);

// output
var_dump($result);
code
 

use Expirenza\short\Link;

$class = new Link('some token', 'https://server.url');

$source = [
    0 => $class->getUniqueFormatItem('https://google.com', 'test_'.time().'_'.random_int(0, 99)),
    1 => $class->getUniqueFormatItem('https://mail.com', 'test_'.time().'_'.random_int(0, 99)),
];

$result = $class->getUniqueMany($source);

// output
var_dump($result);
code

foreach ($result as $item) {
    echo $item->getUrl();
    echo $item->getCode();
    echo $item->getSuccess();
}

foreach ($result as &$item) {
    $item = $item->asArray();
    echo $item['url'];
    echo $item['code'];
    echo $item['success'];
}