Create a time-limited URL

Under certain circumstances, it might be useful to limit the time a link can be used after it was signed.

To do this, Vendo provides a parameter called expires which value is a timestamp after which the URL expires. All time limited links are signed using the URL Signature therefore the expires parameter value cannot be tampered with.

The timestamp must be a unix timestamp. To calculate the expiration timestamp, take the current Unix time and add the seconds you want the URL to be usable.

Example

The example below shows you how to create a one-click link that's valid for the next 15 minutes.
This example uses Vendo's SDK for PHP.

<?php

$ttl = (60 * 15) + time(); // 15 minutes in seconds

include __DIR__ . '/../vendor/autoload.php';

$sharedSecret = 'Your_Vendo_Shared_Secret__get_it_from_us';
$oneclikLink = new \VendoSdk\Url\Oneclick($sharedSecret);
$oneclikLink->setSubscription(222333444555);
$oneclikLink->setOffer(222);
$oneclikLink->setSuccessUrl('http://google.com?ref={REF}');
$oneclikLink->setDeclineUrl('http://yahoo.com?ref={REF}');
$oneclikLink->setRef('refxyz_999_www');
$oneclickLink->setExpires($ttl);

$url = $oneclikLink->getSignedUrl();

//redirect the user to Vendo's payment page
//header('Location: ' . $url);
echo $url . PHP_EOL;