1. Go to this page and download the library: Download greenter/gre-api 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/ */
greenter / gre-api example snippets
$apiInstance = new Greenter\Sunat\GRE\Api\AuthApi(
new GuzzleHttp\Client()
);
$client_id = 'client_id_example'; // El client_id generado en menú sol
$grant_type = 'password';
$scope = 'https://api-cpe.sunat.gob.pe';
$client_secret = 'client_secret_example'; // client_secret generado en menú sol
$username = 'username_example'; // <Numero de RUC> + <Usuario SOL>
$password = 'password_example'; // Contraseña SOL
try {
$result = $apiInstance->getToken($grant_type, $scope, $client_id, $client_secret, $username, $password);
print_r($result);
} catch (Exception $e) {
echo 'Excepcion cuando invocaba AuthApi->getToken: ', $e->getMessage(), PHP_EOL;
}