Page 1 of 1
Converter para Harbour
Posted: Fri Dec 03, 2021 11:10 am
by toya
Alguém poderia me auxiliar converter para Harbour:
Este:
Code: Select all | Expand
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://treinamento.atende.net/atende.php?pg=rest&service=WNERestServiceNFSe&cidade=migra_pinhais',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('XML'=> new CURLFILE('/H:/NFSe/S_NS9_000000003-nfSe.xml')),
CURLOPT_HTTPHEADER => array(
'Authorization: Basic MDkyNDczNDMwMDAxMjA6SXBtQDIwMjE='
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
ou este:
Code: Select all | Expand
POST /atende.php?pg=rest&service=WNERestServiceNFSe&cidade=migra_pinhais HTTP/1.1
Host: treinamento.atende.net
Authorization: Basic MDkyNDczNDMwMDAxMjA6SXBtQDIwMjE=
Content-Length: 196
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="XML"; filename="/H:/NFSe/S_NS9_000000003-nfSe.xml"
Content-Type: text/xml
(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW
Mui grato...
Re: Converter para Harbour
Posted: Fri Dec 03, 2021 6:51 pm
by toya
Já consegui autenticar...
Apenas não está anexando/enviando o arquivo XML...
Code: Select all | Expand
cUrl := "https://treinamento.atende.net/atende.php?pg=rest&service=WNERestServiceNFSe&cidade=migra_pinhais"
cBasic := "MDkyNDczNDMwMDAxMjA6SXBtQDIwMjE="
cFile := "H:\NFSe\S_NS9_000000003-nfSe.xml"
cHost := "treinamento.atende.net"
hDados["XML"] := '/H:/NFSe/S_NS9_000000003-nfSe.xml'
aadd( aHeaders, 'Authorization: Basic MDkyNDczNDMwMDAxMjA6SXBtQDIwMjE=' )
aadd( aHeaders, 'Cookie: PHPSESSID=n1ncgk2pelqls74rh07797atr1; cidade=migra_pinhais' )
AAdd( aHeaders, 'Content-Disposition: form-data; name="XML"; filename='+cFile )
curl_global_init()
if !empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
curl_easy_setopt( hCurl, HB_CURLOPT_ENCODING, "" )
curl_easy_setopt( hCurl, HB_CURLOPT_MAXREDIRS, 10 )
curl_easy_setopt( hCurl, HB_CURLOPT_TIMEOUT, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_FOLLOWLOCATION, 1)
curl_easy_setopt( hCurl, HB_CURLOPT_HTTP_VERSION, HB_CURL_HTTP_VERSION_1_1 )
curl_easy_setopt( hCurl, HB_CURLOPT_CUSTOMREQUEST, "POST" )
curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, hDados["XML"] )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
cError := curl_easy_perform( hCurl )
if !Empty( cError )
MsgInfo( curl_easy_strerror( cError ), "Error cURL" )
endif
cRet := curl_easy_dl_buff_get( hCurl )
curl_easy_reset( hCurl )
endif
curl_global_cleanup()
? cRet
retorno:
Code: Select all | Expand
<?xml version="1.0" encoding="ISO-8859-1"?>
<retorno>
<mensagem>
<codigo>9999 - Arquivo XML da Nota Fiscal de Serviço Eletrônica não enviado!</codigo>
</mensagem>
</retorno>
Re: Converter para Harbour
Posted: Fri Dec 03, 2021 9:56 pm
by wilsongamboa
estimado no soy experto pero
Code: Select all | Expand
hDados["XML"] := hb_jsonencode( memoread( '/H:/NFSe/S_NS9_000000003-nfSe.xml' ) )
saludos
Wilson