-
-
Save fhferreira/cea69df1a0f40080eba732e405c39089 to your computer and use it in GitHub Desktop.
Exemplo de requisição para geração de etiquetas do correios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$usuario = 'sigep'; | |
$senha = 'n5f9t8'; | |
$contrato = '9912208555'; | |
$cartao = '0057018901'; | |
$context = stream_context_create(array( | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false, | |
'allow_self_signed' => true | |
) | |
)); | |
$client = new SoapClient('https://apphom.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl', array( | |
'stream_context' => $context | |
)); | |
$soapArgs = array( | |
'numeroCartaoPostagem' => '0057018901', | |
'usuario' => $usuario, | |
'senha' => $senha | |
); | |
$soapArgs = array( | |
'idContrato' => $contrato, | |
'idCartaoPostagem' => $cartao, | |
'usuario' => $usuario, | |
'senha' => $senha | |
); | |
$servicosResponse = $client->buscaCliente( $soapArgs ); | |
$cnpj = $servicosResponse->return->cnpj; | |
$servicos = []; | |
foreach( $servicosResponse->return->contratos->cartoesPostagem->servicos as $servico ) | |
{ | |
$servicos[ $servico->codigo * 1 ] = $servico->id * 1; | |
} | |
$soapArgs = array( | |
'tipoDestinatario' => 'C', | |
'identificador' => $cnpj, | |
'idServico' => 104672, | |
'qtdEtiquetas' => 1, | |
'usuario' => $usuario, | |
'senha' => $senha | |
); | |
$etiquetasResponse = $client->solicitaEtiquetas( $soapArgs ); | |
$etiqueta = substr($etiquetasResponse->return, 0 ,strpos($etiquetasResponse->return, ',')); | |
$soapArgs = array( | |
'etiquetas' => [substr($etiquetasResponse->return, 0 ,strpos($etiquetasResponse->return, ','))], | |
'usuario' => $usuario, | |
'senha' => $senha | |
); | |
$dvEtiquetasResponse = $client->geraDigitoVerificadorEtiquetas( $soapArgs ); | |
echo $etiqueta; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment