Como utilizar Hbcurl.ch
Enviado: 18 Ago 2022 15:48
ola pessoal,
precisava usar essa biblioteca no harbour mas nao consigo.
to tentando essa alternativa pois usando o metodo POST / SEND()
essa api da erro no windows7, talvez por algum problema de httsp/ssl
ja coloquei
#include "hbcurl.ch"
#include "hbssl.ch"
mas ao compilar aparece diversos erros:
undefined reference to 'HB_FUN_CURL_GLOBAL_INIT'
undefined reference to 'HB_FUN_CURL_EASY_INIT'
undefined referente to 'HB_FUN_CURL_BLOBAL_CLEANUP'
e outras mais....
o que tenho que fazer para conseguir compilar usando essa biblioteca ?
Mais uma vez,
Obrigado !
precisava usar essa biblioteca no harbour mas nao consigo.
to tentando essa alternativa pois usando o metodo POST / SEND()
essa api da erro no windows7, talvez por algum problema de httsp/ssl
ja coloquei
#include "hbcurl.ch"
#include "hbssl.ch"
mas ao compilar aparece diversos erros:
undefined reference to 'HB_FUN_CURL_GLOBAL_INIT'
undefined reference to 'HB_FUN_CURL_EASY_INIT'
undefined referente to 'HB_FUN_CURL_BLOBAL_CLEANUP'
e outras mais....
o que tenho que fazer para conseguir compilar usando essa biblioteca ?
Código: Selecionar todos
PROCEDURE CURL()
curl_global_init()
curl ="https://api2.megaapi.com.br/rest/sendMessage/megaapi-....................."
cbearer='Bearer MPo7viYVx6..... '
rA_TELENVIO='5511996......@s.whatsapp.net'
rA_MSGENVIO='OI ABEL, TESTE CURL'
cjson =hb_jsonEncode( { "messageData" => { "to" => AllTrim( rA_TELENVIO ) , "text" => rA_MSGENVIO } } )
if ! empty( hCurl := curl_easy_init() )
//If there's an authorization token, you attach it to the header like this:
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, {"Authorization: "+cbearer} )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, {"Content-Type: "+"application/json"} )
//Set the URL:
curl_easy_setopt( hCurl, HB_CURLOPT_URL, curl )
//Disabling the SSL peer verification (you can use it if you have no SSL certificate yet, but still want to test HTTPS)
curl_easy_setopt(hCurl, HB_CURLOPT_FOLLOWLOCATION, 1)
curl_easy_setopt(hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0)
//If you are sending a POST method request, you gotta attach your fields with this clause using
//url-encoded pattern
//If you are sending a GET method request, you can just delete this clause, because your parameters will be attached
//directly into your URL
curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, cjson)
//Setting the buffer
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
//Sending the request and getting the response
IF (nret:=curl_easy_perform( hCurl )) == 0
uValue := curl_easy_dl_buff_get( hCurl )
ENDIF
ENDIF
//Cleaning the curl instance
curl_global_cleanup()
//I'm using hb_jsonDecode() so I can decode the responde into a JSON object
hb_jsonDecode(uValue)
ALERT(UVALUE)
RETURNObrigado !