How to open a URL by passing hidden parameter?

Asked

Viewed 1,113 times

0

Need, via Delphi, to open a Url/Site by passing a hidden parameter (not shown in the Url).

I tried to Shellexecute:

ShellExecute(Handle, 'Open', 'http://localhost:49486/admin/Login.aspx?View={1B605F4E-A7C9-4B7B-98B7-5A2D2ADBD520}', nil, nil, 1);

However, it only allows passing the parameter via url, becoming visible.

  • You want to make a POST request. That?

  • If you will perform the request through the language and not through the front-end, what is the need for the parameters not to be "visible"?

  • Exact @jbueno. I need to open the URL with a Post parameter.

  • Kenny on the system in Delphi, will have a shortcut to a restricted screen, with login. This shortcut will pass a certain parameter so that the session is created and you do not need Login. If the parameter is via url, the user can copy this url, and use it directly in the browser, without passing the shortcut in the system (business rule), and pass it to third parties.

  • You could use Indy to give the Post, and have Windows open the return URL with Shellexec.

1 answer

2


I solved the problem using Twebbrowser:

procedure TForm1.Button1Click(Sender: TObject);
var Data: String;
    I: Integer;
    Flags, PostData, Headers: OleVariant;
begin

  Flags := navOpenInNewWindow;
  Data  := 'View={1B605F4E-A7C9-4B7B-98B7-5A2D2ADBD520}';
  PostData := VarArrayCreate([0, Length(Data)-1], varByte);
  for I := 1 to Length(Data) do PostData[I-1] := Ord(Data[I]);
  Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
  WebBrowser1.Navigate('http://localhost:49486/admin/Login.aspx', Flags, EmptyParam, PostData, Headers);

end;

The only detail is that it opens by default in Internet Explorer browser.

  • If you’re going to open the URL from within the application, you won’t be able to escape from the IE (not without some lib). Now if you can open with the default machine browser, it has how to do.

  • To understand, in the GET request the parameters are passed via url, as explained in the question. In your case you need to make a POST request. I recommend that you do this using the Indy components. Search Google for "Delphi Indy post Multipartformdatastream" and you’ll find lots of things... Good luck!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.