PHP code example of nicklasw / bankid-sdk

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

    

nicklasw / bankid-sdk example snippets


$client = new Client(new Config(<CERTFICATE>));

$authenticationResponse = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));

if (!$authenticationResponse->isSuccess()) {
    var_dump($authenticationResponse->getErrorCode(), $authenticationResponse->getDetails());

    return;
}

$collectResponse = $authenticationResponse->collect(); 

$client = new ClientAsynchronous(new Config(<CERTFICATE>));

$promises[] = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));
$promises[] = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));

// Parallel requests, authenticate users
foreach (unwrap($promises) as $result) {
    /**
     * @var AuthenticationResponse $result
     */
    var_dump($result->isSuccess());
}