FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour CURL_GLOBAL_INIT()
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM

CURL_GLOBAL_INIT()

Posted: Tue Apr 06, 2021 03:22 PM
Hello friends.

I'm starting a function using cURL and right at the beginning in "CURL_GLOBAL_INIT()" it gives me an error according to the image.



Would anyone know what it can be?

Thanks
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: CURL_GLOBAL_INIT()

Posted: Tue Apr 06, 2021 04:41 PM

Christiano,

Please post here a small PRG that reproduces the error, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM

Re: CURL_GLOBAL_INIT()

Posted: Tue Apr 06, 2021 05:39 PM
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM

Re: CURL_GLOBAL_INIT()

Posted: Tue Apr 06, 2021 06:21 PM
Antonio, thank you for answering.

Follows the code of what I'm doing

Code (fw): Select all Collapse
#INCLUDE "FIVEWIN.CH" 
#INCLUDE "HBCURL.CH"

FUNCTION TESTE()

    LOCAL ClientID     := "Client_Id_845d87fc2a97b8b4a8aada2f0d9df2aceca50031"
    LOCAL ClientSecret := "Client_Secret_57917244d7a42f96ff2c1ec4e6eeb0740f61eb6c"
    LOCAL hWebService

    CURL_GLOBAL_INIT()
    hWebService := CURL_EASY_INIT()
    
    IF !EMPTY(hWebService)
        
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_URL, "https://sandbox.gerencianet.com.br/v1/charge/one-step")
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_RETURNTRANSFER, .T.)
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_ENCODING, '')
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_MAXREDIRS, 10)
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_TIMEOUT, 0)
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_FOLLOWLOCATION, .T.)
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_CUSTOMREQUEST, "POST")
//      CURL_EASY_SETOPT(hWebService, HB_CURLOPT_POSTFIELDS, {"items": {"name": "Product 1",;
//                                                                      "value": 500,;
//                                                                      "amount": 1},;
//                                                            "shippings": {"name": "Default Shipping Cost",;
//                                                                          "value": 100},                  ;
//                                                            "payment": {"banking_billet": {"expire_at": "2019-10-16",;
//                                                                                           "customer": {"name": "Gorbadoc Oldbuck",;
//                                                                                           "email": "gorb.oldbuck@gerencianet.com.br",;
//                                                                                           "cpf": "14014603059",;
//                                                                                           "birth": "1977-01-15",;
//                                                                                           "phone_number": "62986070247"}}}})
        CURL_EASY_SETOPT(hWebService, HB_CURLOPT_HTTPHEADER,array('Authorization: {{Authorization}}','Content-Type: application/json'))
    
    ENDIF
    
    CURL_GLOBAL_CLEANUP()

RETURN NIL
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: CURL_GLOBAL_INIT()

Posted: Wed Apr 07, 2021 08:06 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM

Re: CURL_GLOBAL_INIT()

Posted: Thu Apr 08, 2021 05:38 PM
Hello Mr. Antonio

I removed the code CURL_GLOBAL_INIT () and CURL_GLOBAL_CLEANUP () as mentioned in your answer and stopped the error. Thank you!

Now if possible I would have two more doubts.

1st - In the PHP code I am using as a reference there is the command:

Code (fw): Select all Collapse
$ response = curl_exec ($ curl);


what is your correspondence in HB_CURL?

2nd - Regarding CURL_EASY_INIT (), wouldn't you have to close it with an IF?

Thank you!
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: CURL_GLOBAL_INIT()

Posted: Fri Apr 09, 2021 10:48 AM

I would say it is curl_easy_perform( hCurl )

viewtopic.php?p=240120sid=f48eff6a559c156b39000315c6649994#p240120

> 2nd - Regarding CURL_EASY_INIT (), wouldn't you have to close it with an IF?

Yes, right

&

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion