FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour hbcurl xharbour
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
hbcurl xharbour
Posted: Tue Jul 18, 2023 06:48 PM

Hi, Does anyone know how to rewrite this routine using hbcurl? Thanks in advance.

TRY

oUrl = TUrl():New( 'https://www.averbeporto.com.br/websys/php/conn.php' )

CATCH

CurSorArrow()

MsgInfo('Erro ao criar a conexão','Erro')

RETURN(.F.)

END

IF !EMPTY( oUrl )

oCli = TIPClientHttp():New( oUrl )

IF !EMPTY( oCli )

  oCli:nConnTimeout = -1

  IF oCli:Open()

     hQuery["mod"]  := "login"

     hQuery["comp"]  := "5"

     hQuery["user"]  := "USERNAME"

     hQuery["pass"]  := "PASSWD"

     oCli:cUserAgent:='Mozilla/5.0 (compatible; Indy Library)'

     IF !oCli:PostMultiPart(hQuery)

        CurSorArrow()

            MsgInfo(oCli:lastErrorMessage,'Erro')

     ELSE

        cNFSeResp :=oCli:ReadAll()

        RespC     := oCli:GetCookies() // Captura cookie

     ENDIF

     //oCli:Close()

  ENDIF

ENDIF

ENDIF

If Alltrim(cNFSeResp) == '{"success":1,"logout":1}'

CurSorArrow()

oCli:Close()

MsgBeep()

MsgAlert("Não foi possível conectar ao site de averbação!","Atenção")

Return .f.

Endif

// Faz o upload do xml para averbação

oCli:Close()

oCli = TIPClientHttp():New( oUrl )

IF !EMPTY( oCli )

  oCli:nConnTimeout = -1

  IF oCli:Open()

     ocli:SetCookie( respc )

     hQuery["comp"]   := "5"

     hQuery["mod"]    := "Upload"

     hQuery["path"]   := "eguarda/php/"

     hQuery["recipient"]   := ""



     EmiCte := Dtoc(oArqCto:DTEMIS)

        LocXml := Alltrim(oConfCte:P_AUTORI)+Substr(EmiCte,4,2)+Substr(EmiCte,7,4)+"\"+Alltrim(oArqCto:CHAVESEFAZ)+;

                  "-ProcCTe.xml"



        If ! File(LocXml)

        CurSorArrow()

           MsgBeep()

            MsgAlert("Xml do cte não localizado!","Atenção")

            oCli:Close()

            Return .f.

        Endif



     ArqAtach := LocXml



     oCli:cUserAgent:='Mozilla/3.0 (compatible; Indy Library)'

     oCli:Attach("file",ArqAtach)



     IF !oCli:PostMultiPart(hQuery)

        CurSorArrow()

        MsgInfo(oCli:lastErrorMessage,'Erro')

     ELSE

        Respchave:=oCli:ReadAll()

     ENDIF

  ENDIF

ENDIF

If Substr(Alltrim(Respchave),1,12) == '{"success":0'

CurSorArrow()

oCli:Close()

MsgBeep()

MsgAlert("Não foi possível fazer o upload do arquivo xml!","Atenção")

MsgAlert(Repchave)

Return .f.

Endif

Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: hbcurl xharbour
Posted: Wed Aug 09, 2023 01:57 PM

Any idea?

Continue the discussion