Skip to content

Instantly share code, notes, and snippets.

@estebandelaf
Created May 23, 2020 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estebandelaf/5cec4e377a7459e83561bf848abaa4f9 to your computer and use it in GitHub Desktop.
Save estebandelaf/5cec4e377a7459e83561bf848abaa4f9 to your computer and use it in GitHub Desktop.
Ejemplo de pre-autenticación con LibreDTE y SowerPHP
<?php
// ejemplo de uso
libredte_preauth('hash-del-usuario', 76192083, '/dte/dte_emitidos');
/**
* Función para preautenticar y redireccionar a un usuario en LibreDTE
* @param hash Hash del usuario, está en su perfil
* @param rut RUT del contribuyente sin DV
* @param uri Donde se desea enviar al usuario luego de autenticar y seleccionar contribuyente
* @param url URL base de la aplicación web de LibreDTE
*/
function libredte_preauth($hash, $rut, $uri = '/dte', $url = 'https://libredte.cl')
{
$redirect = base64_encode('/dte/contribuyentes/seleccionar/'.$rut.'/'.base64_encode($uri));
header('location: '.$url.'/usuarios/preauth/'.$hash.'/0/'.$redirect);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment