04-20-2022, 03:55 PM
(04-20-2022, 11:16 AM)staff@ergosoft.it Wrote: this is an examples in php of autentication:
...
How in delphi ?
Something like this:
Code:
uses
..., Classes, IdGlobal, IdHTTP, IdSSLOpenSSL;
var
http: TIdHTTP;
ssl: TIdSSLIOHandlerSocketOpenSSL;
postData: TStream;
response: String;
begin
try
// alternatively, you can configure these components at design-time instead...
http := TIdHTTP.Create(nil);
try
http.HTTPOptions := http.HTTPOptions + [hoKeepOrigProtocol];
http.ProtocolVersion := pv1_1;
http.ReadTimeout := 30000;
http.RedirectMaximum := 10;
http.Request.CacheControl := 'no-cache';
http.Request.ContentType := 'text/xml';
http.Request.CustomHeaders.Values['token'] := '0435a03b361d7cc24fc1acacdeaae1d7';
ssl := TIdSSLIOHandlerSocketOpenSSL.Create(http);
ssl.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
ssl.VerifyMode := [];
ssl.VerifyDepth := 0;
http.IOHandler := ssl;
postData := TIdReadFileExclusiveStream.Create('<path to>\Products.xml');
try
response := http.Post('https://miohost.bindcommerce.cloud/integrator-tool/api/products.php?connector=N', postData);
finally
postData.Free;
end;
finally
http.Free;
end;
// use response as needed...
except
on E: Exception do
// use E as needed...
end;
end;