PHP code example of basekit / signed-url

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

    

basekit / signed-url example snippets


$urlSigner = new BaseKit\SignedUrl('secret');
$url = $urlSigner->sign('http://dev.app', new \DateTime("+ 10 days"));
echo $url;
// http://dev.app?expires=1597606297&signature=2bcbe00d36010bae3e6bc6e6abe79f6cbc135f360285eeb17e9c53753b4b223a"

$urlSigner = new BaseKit\SignedUrl('secret');
$url = $urlSigner->sign('http://dev.app');
echo $url;
// http://dev.app?expires=1597606297&signature=2bcbe00d36010bae3e6bc6e6abe79f6cbc135f360285eeb17e9c53753b4b223a"

$url = "http://dev.app?expires=1597606297&signature=2bcbe00d36010bae3e6bc6e6abe79f6cbc135f360285eeb17e9c53753b4b223a";
$urlSignValidator = new BaseKit\SignedUrl('secret');
$valid = $urlSignValidator->validate($url);
var_dump($valid);
// bool(true)


$urlSigner = new BaseKit\SignedUrl('secret', 'expirationParam', 'secureSignature');
$url = $urlSigner->sign('http://dev.app', new \DateTime("+ 10 days"));
echo $url;
// https://www.dev.app/?expirationParam=1597608096&secureSignature=ef6839ad6b1a4cfca8e3e04bb2a74da0e9d3d9c4d9870125f499f75c9ef5d2b6