Tema: post a web
Ver Mensaje Individual
  #4  
Antiguo 27-04-2023
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Reputación: 20
oscarac Va por buen camino
encontré un ejemplo, pero me esta apareciendo un error indicando que las librerias no estan cargadas
"could not load SSL library", en la linea
IdHTTP1.Post('https://zona-api.aris.com.pe/v1/user/signin', S, M);

busque aqui
http://delphiaccess.com/foros/index....d-ssl-library/

descargue las librerias las copie en la carpeta de la aplicacion y nada... sigue lo mismo


Código Delphi [-]
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdMultipartFormData,IdSSLOpenSSL,
  Vcl.StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP;

type
  TForm1 = class(TForm)
    IdHTTP1: TIdHTTP;
    Button1: TButton;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var S: TStringList;
   M: TStream;
   lHTTP: TIdHTTP;
begin
 S := TStringList.Create;
 M := TMemoryStream.Create;
 try
   S.Values['user'] := 'usuario';
   S.Values['password'] := 'clave';
   lHTTP := TIdHTTP.Create;

   IdHTTP1.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
   IdHTTP1.Request.ContentType := 'multipart/form-data';
   IdHTTP1.Post('https://zona-api.aris.com.pe/v1/user/signin', S, M);
   Memo1.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
   Memo1.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

   M.Position := 0;
   S.LoadFromStream(M);
   Memo1.Lines.AddStrings(S);
 finally
   S.Free;
   M.Free;
 end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
begin
///
 IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(self);
  with idSSLIOHandlerSocketOpenSSL1 do
    begin
      SSLOptions.Method := sslvSSLv2;
      SSLOptions.Mode := sslmUnassigned;
      SSLOptions.VerifyMode := [];
      SSLOptions.VerifyDepth := 0;
      //host := '';
    end;
   IdHTTP1 := TIdHTTP.Create(Self);
  with IdHTTP1 do
    begin
      IOHandler := IdSSLIOHandlerSocketOpenSSL1;
      AllowCookies := True;
      ProxyParams.BasicAuthentication := False;
      ProxyParams.ProxyPort := 0;
      Request.ContentLength := -1;
      Request.ContentRangeEnd := 0;
      Request.ContentRangeStart := 0;
      Request.Accept := 'text/html, */*';
      Request.BasicAuthentication := False;
      Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';
      HTTPOptions := [hoForceEncodeParams];
    end;
end;

end.
__________________
Dulce Regalo que Satanas manda para mi.....

Última edición por oscarac fecha: 27-04-2023 a las 21:25:14.
Responder Con Cita