PHP code example of atalanda / signature-php

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

    

atalanda / signature-php example snippets

 javascript
{ 
  "gnature-php": "dev-master"
  }
}
 php
$parameters = array(
  "atalogics" => array()
);
$token = new Atalogics\Signature\Token("[Your API key]", "[Your API secret]");
$request = new Atalogics\Signature\Request("POST", "https://atalogics.com/api/order", $parameters);
$signedParameters = $request->sign($token);

var_dump($signedParameters);
/* => array(5) {
  'atalogics' => array()
  'auth_timestamp' =>
  int(1391167211)
  'auth_key' =>
  string(4) "[Your API key]"
  'auth_signature' =>
  string(64) "552beac4b99949a556b120b7e5f7e22def46f663992a08f0f132ad4afee68b9f"
}*/
 php
$data = json_decode($body, true); // convert json from post body into php array
$token = new Atalogics\Signature\Token("[Your API key]", "[Your API secret]");
$request = new Atalogics\Signature\Request("POST", "https://your-server.com/callback", $data);
$signatureCheckResult = $request->authenticate($token);

if($signatureCheckResult["authenticated"] === true) {
  // signature is valid
}