1. Go to this page and download the library: Download finpin/sezame-sdk 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/ */
finpin / sezame-sdk example snippets
$client = new \SezameLib\Client();
$registerRequest = $client->register()->setEmail('[email protected]')->setName('my new client');
$registerResponse = $registerRequest->send();
$clientcode = $registerResponse->getClientCode();
$sharedsecret = $registerResponse->getSharedSecret();
use Endroid\QrCode\Writer;
$client = new \SezameLib\Client($certfile, $keyfile);
$username = 'foo-client-user';
// check pairing status of a certain user
$statusRequest = $client->linkStatus();
$statusResponse = $statusRequest->setUsername($username)->send();
if ($statusResponse->isLinked()) {
print "user already has been linked\n";
die;
}
$linkRequest = $client->link();
$linkResponse = $linkRequest->setUsername($username)->send();
if ($linkResponse->isDuplicate()) {
print "user already has been linked\n";
die;
}
$qrCode = $linkResponse->getQrCode($username);
$qrCode->setSize(300)->setLabelMargin([
't' => 10,
'r' => 10,
'b' => 10,
'l' => 10,
]); // optionally adjust qrcode dimensions
printf('<img src="%s"/>', $qrCode->writeString(Writer\PngDataUriWriter::class));
file_put_contents('qrcode.html', sprintf('<img src="%s"/>', $qrCode->writeString(Writer\PngDataUriWriter::class)));
$client = new \SezameLib\Client($certfile, $keyfile, $keyPassword);
$username = 'foo-client-user';
$timeout = 10;
$authRequest = $client->authorize();
$authRequest->setUsername($username);
$authResponse = $authRequest->send();
if ($authResponse->isNotfound()) {
// user not paired
}
if ($authResponse->isOk())
{
$statusRequest = $client->status();
$statusRequest->setAuthId($authResponse->getId());
for ($i = 0; $i < $timeout; $i++)
{
$statusResponse = $statusRequest->send();
if ($statusResponse->isAuthorized())
{
// request has been authorized
}
if ($statusResponse->isDenied())
{
// request has been denied
}
sleep(1);
}
printf("user did not respond within %d seconds\n", $timeout);
}
$client = new \SezameLib\Client($certfile, $keyfile, $keyPassword);
$username = 'foo-client-user';
$authRequest = $client->authorize();
$authRequest->setType('fraud');
$authRequest->setUsername($username);
$authResponse = $authRequest->send();
if ($authResponse->isNotfound()) {
// user not paired
}
if ($authResponse->isOk())
{
printf("user notified about possible fraud attempt\n");
}
$client = new \SezameLib\Client($certfile, $keyfile, $keyPassword);
$client->cancel()->send();