PHP code example of barseghyanartur / ska

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

    

barseghyanartur / ska example snippets



use SKA;

$signedData = SKA\signatureToDict("user", "your-secret_key");
print_r($signedData);

Array
(
    [signature] => WEwnd40jMusHD6hRZ9WOCR8Zym4=
    [auth_user] => user
    [valid_until] => 1631795130.0
    [extra] => 
)

$signedData = SKA\signatureToDict(
    "user", 
    "your-secret_key", 
    [
        "email" => "[email protected]",
        "first_name" => "John",
        "last_name" => "Doe",
    ]
);
print_r($signedData);

Array
(
    [signature] => B0sscS+xXWU+NR+9dBCoGFnDtlw=
    [auth_user] => user
    [valid_until] => 1631797926.0
    [extra] => email,first_name,last_name
    [email] => [email protected]
    [first_name] => John
    [last_name] => Doe
)

$signedData = SKA\signatureToDict(
    "user", 
    "your-secret_key", 
    [
        "email" => "[email protected]",
        "first_name" => "John",
        "last_name" => "Doe",
    ],
    [
        "authUserParam" => "webshop_id"  
    ]
)
print_r($signedData);

Array
(
    [signature] => nu0Un+05z/cNOFnLwQnigoW/KmA=
    [webshop_id] => user
    [valid_until] => 1631799172.0
    [extra] => email,first_name,last_name
    [email] => [email protected]
    [first_name] => John
    [last_name] => Doe
)

$validationResult = SKA\validateSignedRequestData(
    $request->GET, // Note, that `$request->GET` is given as example.
    "your-secret_key"
);

$validationResult = SKA\validateSignedRequestData(
    $request->GET,
    "your-secret_key",
    [
        "authUserParam" => "webshop_id"
    ]
);
shell
php examples/kitchen_sink.php