I'm leaving here a simple explanation of how to use CURL with modharbour:
STEP 1: Attach the hbcurl.ch file to your project
*You can find it right here:
https://github.com/harbour/core/tree/ma ... rib/hbcurl
STEP 2: Include it in your prg file like this
Código: Seleccionar todo
#include "..\include\hbcurl.ch"
Código: Seleccionar todo
curl_global_init()
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: "+cHeader} )
//Set the URL:
curl_easy_setopt( hCurl, HB_CURLOPT_URL, "http://example.com" )
//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, "example=param&example2=param2...")
//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)