CURL_GLOBAL_INIT()

CURL_GLOBAL_INIT()

Postby ctoas » Tue Apr 06, 2021 3: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.

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
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: CURL_GLOBAL_INIT()

Postby Antonio Linares » Tue Apr 06, 2021 4:41 pm

Christiano,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: CURL_GLOBAL_INIT()

Postby hmpaquito » Tue Apr 06, 2021 5:39 pm

hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: CURL_GLOBAL_INIT()

Postby ctoas » Tue Apr 06, 2021 6:21 pm

Antonio, thank you for answering.

Follows the code of what I'm doing

Code: Select all  Expand view

#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
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: CURL_GLOBAL_INIT()

Postby Antonio Linares » Wed Apr 07, 2021 8:06 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: CURL_GLOBAL_INIT()

Postby ctoas » Thu Apr 08, 2021 5: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: Select all  Expand view
$ 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
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: CURL_GLOBAL_INIT()

Postby Antonio Linares » Fri Apr 09, 2021 10:48 am

I would say it is curl_easy_perform( hCurl )

viewtopic.php?p=240120&sid=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
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 88 guests