PHP code example of mingalevme / utils-secure-link

1. Go to this page and download the library: Download mingalevme/utils-secure-link 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/ */

    

mingalevme / utils-secure-link example snippets




const SECRET = 'YOUR_SECRET_KEY';

use Mingalevme\Utils\Url\SecureLink;

$signer1 = new SecureLink(SECRET);

echo $signer1->sign('https://github.com/mingalevme/secure-link-php');
// https://github.com/mingalevme/secure-link-php?signature=13-dGaz-frzJ9qUg3iQ0RA%3D%3D

echo $signer1->sign('https://github.com/mingalevme/secure-link-php', 3600); 
// https://github.com/mingalevme/secure-link-php?expires=1526392953&signature=GOzCrktWlWDvSWVH49qjUQ%3D%3D

$signer2 = new SecureLink(SECRET, [
    'signatureArgName' => '_sig',
    'expiresArgName' => '_expires',
]);

echo $signer2->sign('https://github.com/mingalevme/secure-link-php', 3600);
// https://github.com/mingalevme/secure-link-php?_expires=1526393056&_sig=biyetWW5IgBPUftLF1SaOw%3D%3D



const SECRET = 'YOUR_SECRET_KEY';

use Mingalevme\Utils\Url\SecureLink;

$signer1 = new SecureLink(SECRET);

if (!$signer1->isValid('https://github.com/mingalevme/secure-link-php?_expires=1526393056&_sig=biyetWW5IgBPUftLF1SaOw%3D%3D')) {
    throw new Exception('Url is invalid or expired');
}