PHP code example of magiclabs / magic-admin-php

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

    

magiclabs / magic-admin-php example snippets






    $did_token = \MagicAdmin\Util\Http::parse_authorization_header_value(
    $authorization_header
  );

  if ($did_token === null) {
    // DIDT is missing from the original HTTP request header. You can handle this by
    // remapping it to your application error.
  }

  $magic = new \MagicAdmin\Magic('<YOUR_API_SECRET_KEY>');

  try {
    $magic->token->validate($did_token);
    $issuer = $magic->token->get_issuer($did_token);
  } catch (\MagicAdmin\Exception\DIDTokenException $e) {
    // DIDT is malformed. You can handle this by remapping it
    // to your application error.
  }

$magic = new \MagicAdmin\Magic(
  '<YOUR_API_SECRET_KEY>',
  5,    // timeout
  3,    // retries
  0.01  // backoff
);
bash
composer 
bash
./vendor/bin/phpunit tests/MagicTest.php