Created
July 11, 2023 11:39
-
-
Save dkounal/b8ab592c74d668ccbd1b3c7536a31623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not CurlIsAvailable then exit('no curl available'); | |
res:=crFailedInit; | |
hnd:=curl.easy_init; | |
if hnd <> Nil then | |
begin | |
curl.easy_setopt(hnd, coSSLVerifyPeer, 0); | |
curl.easy_setopt(hnd, coSSLVerifyHost, 0); | |
curl.easy_setopt(hnd, coURL, Pointer(url)); | |
curl.easy_setopt(hnd, coUserName, Pointer(uname)); | |
curl.easy_setopt(hnd, coPassword, Pointer(passw)); | |
headers:=nil; | |
headers := curl.slist_append(headers, Pointer(FormatUtf8('accept: %', ['application/xml']))); | |
headers := curl.slist_append(headers, Pointer(FormatUtf8('api-key: %', [applkey]))); | |
curl.easy_setopt(hnd, coHttpHeader, headers); | |
curl.easy_setopt(hnd, coCustomRequest, RawUtf8('GET')); | |
curl.easy_setopt(hnd, coWriteData, @responseData); | |
curl.easy_setopt(hnd, coWriteFunction, @CurlWriteRawByteString); | |
res := curl.easy_perform(hnd); | |
if res = crOk then result:=responseData | |
else | |
begin | |
result:=Format('Curl told us %d (%s)', [Ord(res), curl.easy_strerror(res)]); | |
responseData := ''; | |
end; | |
curl.slist_free_all(headers); | |
curl.easy_cleanup(hnd); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment