Ver Mensaje Individual
  #13  
Antiguo 23-12-2008
Bauhaus1975 Bauhaus1975 is offline
Miembro
 
Registrado: may 2005
Ubicación: Málaga
Posts: 135
Reputación: 20
Bauhaus1975 Va por buen camino
Hola, vuelvo a recuperar este hilo.
Resulta que yo también he tenido estos problemas de incompatibilidad. Estaba usando Delphi 6, y ahora trabajo sobre BStudio 2005 para Win32.

Tengo un procedimiento para capturar páginas por HTTP, mediante GET o POST, y he usado los consejos que se detallan al principio de este post para adaptarlo a mi nuevo IDE.

Resulta que no sé cómo hacer que los métodos GET o POST puedan aceptar una URL que venga en una variable. Tal y como en el ejemplo de código que adjunto estoy haciendo...
Gracias y un saludo.

Código Delphi [-]
function captureHTTP(URL, strParams:String; objCont:TComponent; method:String):String;
Var
  aStream: TMemoryStream;
  Params: TStringStream ;
  HTTP: TidHTTP;
begin
  HTTP := TIdHTTP.Create(objCont);
  HTTP.HandleRedirects := true;
  Params := TStringStream.create('');
  aStream := TMemoryStream.create;
  if (method = 'post') then
 HTTP.Request.ContentType := 'application/x-www-form-urlencoded';
  try
    with HTTP do begin
      try
        if (method = 'post') then
            HTTP.Post(URL, Params, aStream)
        else
            HTTP.Get(URL+strParams,aStream);
        end;
      except
        on E: Exception do
          showmessage('Error al intentar hacer HTTP REQUEST: ' + E.Message);
      end;
    end;
    aStream.WriteBuffer(#0' ', 1);
  except
  end;
  result := PChar(aStream.Memory);
end;
Responder Con Cita