PHP code example of regalii / regaliator

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

    

regalii / regaliator example snippets


$configuration = new Regaliator\Configuration([
  'version' => '3.1',
  'api_host' => 'api.casiregalii.com',
  'api_key' => getenv('REGALII_API_KEY'),
  'secret_key' => getenv('REGALII_SECRET')
]);
$regaliator = new Regaliator\Regaliator($configuration);

$response = $regaliator->account();

if ($response->success) {
  $data = json_decode($response->body, true);
} else {
  echo "Failed with status code {$response->status_code}";
}

$response = $regaliator->create_credentials_bill(12376, 'login', 'challengeme');
$bill = json_decode($response->body, true);
echo "Created bill {$bill['id']}\n";

function poll_while_updating($regaliator, $id) {
  for($i = 0; $i < 60; $i++) {
    echo "Checking status for bill {$id} after sleeping 1 second\n";
    sleep(1);

    $response = $regaliator->show_bill($id);
    $bill = json_decode($response->body, true);

    if ($bill['status'] !== 'fetching') {
      return $bill;
    }
  }
  // raise exception because bill is still fetching
}

$bill = poll_while_updating($regaliator, $bill['id']);

$response = $regaliator->update_bill_mfas($bill['id'], ['mfa_challenges' => [
  [
    'id' => $bill['mfa_challenges'][0]['id'],
    'type' => $bill['mfa_challenges'][0]['type'],
    'response' => '8'
  ]
]]);