"...programar es fácil, hacer programas es difícil..."
UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
I linked in the libraries, but when I tried to put in init(), I now get the error message that it cannot run because libcurl-x64.dll cannot be found.
I have the FW Harbour builds for 64bit (22.03) and I use Visual Studio 2022. There are NO .dll files in harbour, and that one is also not present in the FWH builds.
Where can I get this .dll ?
#include "FiveWin.ch"
Function Main()
local oWnd, oActiveX1, oActiveX2, cTemp
DEFINE WINDOW oWnd TITLE "FiveWin multiple ActiveX support"
@ 5, 5 BUTTON "&API TEST" OF oWnd SIZE 100, 40 ACTION TestAPI()
ACTIVATE WINDOW oWnd
return nil
function TestAPI()
local oHttp
local cUrl := "https://petstore.swagger.io/v2/pet/1000"
local hDatos := { => }
local uResponse, cCookies, I, cLink
local cData
// Data to change
cData := '{ "name": "Noyca", "status" : "available" }' // PETSTORE
// Other samples of links that maybe can help (more data insite the url)
// cUrl = "https://yoursite/api/v2/products/"+alltrim(cCode)+"?search=sku&token=yourtoken"
// This line will read the url with data and respond with uResponse.
MsgRun( cUrl, "READING API PAGE", { || uResponse := WebPageContents( cUrl, .t. ) } )
XBrowser( uResponse ) FASTEDIT
hb_JsonDecode( uResponse, @hDatos ) // -> Hash
XBrowser( hDatos ) FASTEDIT
cUrl := "https://petstore.swagger.io/v2/pet/"
oHttp := FWGetOleObject( "WINHTTP.WinHttpRequest.5.1" )
WITH OBJECT oHttp
:SetTimeouts(0, 60000, 30000, 120000)
:Open( "POST", cUrl, .f. )
:SetRequestHeader( "Accept", "application/json" )
:SetRequestHeader( "Content-Type", "application/json" )
:Send( cData )
:WaitForResponse()
? :Status, :StatusText // 200 OK
END
return nilI also noticed that for some API's I had to change :
:Open( "POST", cUrl, .f. )
to
:Open( "PATCH", cUrl, .f. )
function _createObject()
local oOle
try
oOle := CreateObject( "msxml2.xmlhttp.6.0" )
catch
try
oOle := CreateObject( "msxml2.xmlhttp" )
catch
try
oOle := CreateObject( "microsoft.xmlhttp" )
catch
oOle := Cil
end
end
end
return oOlefunction curl_test()
local pCurl := curl_easy_init()
local nRc, cBuffer, oError
try
if hb_isPointer( pCurl )
curl_easy_setopt( pCurl, HB_CURLOPT_URL, "https://harbour.page/test" )
//? curl_easy_setopt( pCurl, HB_CURLOPT_POST, .t. )
//? curl_easy_setopt( pCurl, HB_CURLOPT_POSTFIELDS, hb_jsonEncode( { "user" => "demo", "pass" => "demo" } ) )
// if need to ignore certificate
// curl_easy_setopt( pCurl, HB_CURLOPT_SSL_VERIFYPEER, .f. )
// curl_easy_setopt( pCurl, HB_CURLOPT_SSL_VERIFYHOST, .f. )
if ( nRc := curl_easy_perform( pCurl, @cBuffer ) ) == 0
? cBuffer
else
cBuffer := curl_easy_strerror( nRc )
? "error: ", cBuffer
endif
curl_easy_cleanup( pCurl )
endif
catch oError
? oError:description
end
return nilTimStone wrote:Antonio and Lallton,
I really don't believe my question deserved those last two VERY RUDE responses.
The company I am working on has an NDA in place, so I modified the webaddress, and the user ID in the example. Everything was exactly the way I am using it. Nothing is FAKE. I was not asking you to replicate the call. It is not to a public website so you could not do that.
My last question was twofold, and simple:
1). Would Harbour cURL be better than the Microsoft based call in the original post on this thread ?
2). If the answer is yes, where can I see documenation on how to use Harbour's cURL, and is there a .prg in the Samples folder.
As one who has been a part of this community since the earliest FiveWin days, and updated every year, I don't believe such disrespectful comments were necessary, and they were not appreciated.
If you can respond to the two actual questions, I would appreciate it.
Tim
Hi Marc,
I appreciate the follow up. I wanted to work with the hbcurl.lib but it requires libcurl-x64.dll and I can't find it .... at least not in my FW and Harbour distributions, or anywhere else on my computer.
When you do the last part of your test, you ? status, but what do you use for seeing the values returned ? Also, you use POST, but my effort is a GET.
I had reviewed your thread on this previously. The MsgRun( ) is closest to what I need to accomplish because they prefer everything to be sent in a single submission ( your "Other" line ). How does that actually work ?
Thanks.
It is what I use with MSVC64 no sure if is compatible but you can try.
https://drive.google.com/file/d/13fkv2M ... sp=sharing
Regards,
Llalton,
As I shared, I was not expecting testing. That's why "fake" was not received well. I had to honor my NDA agreement with vendor, so I couldn't provide the actual website and my ID.
As I tried to make clear, it is their NEW API and their NEW server that is giving me the problem. In the standard call, I can open the server, but my Send( oData ) is not seeing it on their end. I think that is because they want the whole string sent ( URL + Data ). This change came after I spent weeks communicating with them, building the integration to their product that they wanted, having it ALL fully functional, and then having them suddenly tell me they want me to use a new API and Server .... so the frustration is very real here.
I think the curl_easy is a good way to go because it appears it will accomodate what they want. Because I subscribe and have the latest Harbour and FW builds from FiveTech, I do have the libcurl.lib and hbcurl.lib. I am working with the 64 bit version, and when I try to do an init() I get the error that it can't find libcurl-x64.dll. So right now, that is my need. I need to find that particular file, compatible with Visual Studio build ( and I use VS 2022 ). I think I've gathered enough knowledge today to start working with it once I can get that .dll.
I'm sure your samples ( which I will put in my notes ) will be helpful.
Tim
It appears under shared files, there is only the 32 bit libcurl.dll
Hi Tim, I totally understand.
It is 64bits. I sent you an invite on Skype in case you need something message me and I can try to help you.
Regards,
Thank you for the files. I now get a successful build with init() set ...
I can now start working with curl-easy- and see if I can get what I want. I believe I can based on the threads I have read so far. I appreciate the offer of online help, but at this point, trial and error will help me understand the capabilities, and allow me to use the options more broadly.
I will update this thread as I move further into the process.
Tim
I want to thank the contributors to this thread.
I have now modified my code to use curl_easy capability and it is working well.
This will also allow me to expand some other capabilities within this program.
I asked questions so I would understand what I am doing, and the responses helped. I would love to see documentation for the full use of this capability, but I realize no one documents any longer except to maybe publish notes about changes.
Tim
Excellent Tim
It is a nice documentation about libcurl ( maybe can help )
https://everything.curl.dev/libcurl