PHP code example of belazz / esia-legacy

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

    

belazz / esia-legacy example snippets


 
$config = new \Esia\Config([
  'clientId' => 'INSP03211',
  'redirectUrl' => 'http://my-site.com/response.php',
  'portalUrl' => 'https://esia-portal1.test.gosuslugi.ru/',
  'privateKeyPath' => 'my-site.com.pem',
  'privateKeyPassword' => 'my-site.com',
  'certPath' => 'my-site.com.pem',
  'tmpPath' => 'tmp',
  'scope' => ['fullname', 'birthdate'],
]);
$esia = new \Esia\OpenId($config);

$esia->getConfig()->getOid();

$config->setToken($jwt);
$config->setOid($oid);


$esia = new \Esia\OpenId($config);

// Вы можете использовать токен в дальнейшем вместе с oid 
$token = $esia->getToken($_GET['code']);

$personInfo = $esia->getPersonInfo();
$addressInfo = $esia->getAddressInfo();
$contactInfo = $esia->getContactInfo();
$documentInfo = $esia->getDocInfo();