Jump to content

Delphi PrestaShop API Example


IanB

Recommended Posts

After a LOT of experimentation and analyzing network captures the following works:

 

procedure TForm7.DoOnAuthorization(Sender: TObject;
  Authentication: TIdAuthentication; var Handled: Boolean);
begin
  Authentication.Username := ShopKey;
  Authentication.Password := '';
  Handled := true;
end;
 
procedure TForm7.DoOnSelectAuthorization(Sender: TObject;
  var AuthenticationClass: TIdAuthenticationClass; AuthInfo: TIdHeaderList);
begin
  AuthenticationClass := TIdBasicAuthentication;
end;
 
procedure TForm7.FormCreate(Sender: TObject);
var  
  SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
  s: string;
begin
  Client := TIdHttp.Create(self);
  Client.OnAuthorization := DoOnAuthorization;
  Client.OnSelectAuthorization := DoOnSelectAuthorization;
  Client.HTTPOptions := Client.HTTPOptions + [hoInProcessAuth];  
  Client.Request.Accept := '';
  Client.Request.AcceptEncoding := '';
  Client.Request.UserAgent := '';
 
  s := Client.Get('http://mysite.com/api');

end;

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...