1. Go to this page and download the library: Download farit-slv/esia-connector 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/ */
farit-slv / esia-connector example snippets
$config = new \Esia\ConfigWithoutKeyPair([
'clientId' => 'U407501', /* Код вашей организации в ЕСИА */
'redirectUrl' => 'http://localhost:8000/',
'portalUrl' => 'https://esia-portal1.test.gosuslugi.ru/',
'scope' => [
'fullname', /* Просмотр вашей фамилии, имени и отчества */
],
]);
$signer = new HttpSigner(
'http://localhost:3037/cryptopro/sign',
[
'Content-Type' => 'application/json',
'accept' => '*/*',
],
'POST',
);
$esia = new \Esia\OpenId($config);
$esia->setSigner($signer);
<a href="<?=$esia->buildUrl()
$esia = new \Esia\OpenId($config);
$esia->setSigner(new \Esia\SignerPKCS7(
$config->getCertPath(),
$config->getPrivateKeyPath(),
$config->getPrivateKeyPassword(),
$config->getTmpPath()
));
// Вы можете использовать токен в дальнейшем вместе с oid
$token = $esia->getToken($_GET['code']);
$personInfo = $esia->getPersonInfo();
$esia->getConfig()->getOid();
$config->setToken($jwt);
$config->setOid($oid);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.