Jump to content
frankie1

https, post, login, get data from https site within android and .exe from delphi code

Recommended Posts

Hi, am not developing very often, almost 0 knowledge on networking programming.

I am trying to build an app (both .exe and android) that logs in a https site (user and password) and manipulate data retrieved from the site. I have read around and the things got very confusing because of the 2 dlls that i have to put inside .exe folder (for https to work -openssl). Also on android version_n (don't remember the number) there's no support for openssl (that delphi uses, or indy at least - very confusing for non-dayly-programmers) because they switched to boringssl. So all this throws a lot of difficulty and confusion for me; besides logging in to the https site, i need to get some data from that site that is displayed on browser screen(for example) after you press a button on that web page. So there's the need to manipulate the web page elements within the application, wait for the info, and fetch it and manipulate it. Now the questions: is delphi capable to generate .exe and android version of this program? (without installing n addons and troubleshoot possible install bugs?) If so, what would be the easiest approach? Please post a very small snippet that works.

 

What i have tried: nothing so far, i have just read the infos on how delphi works with https and found it is somehow frustrating for me. If there's no elegant solution, i might go for other programming language for this app

 

site example: https://abc.def.com/loginform.aspx

 

; people from stackoverflow considered i should ask this on delphipraxis

Share this post


Link to post

You don't have to use OpenSSL. Delphi has own HTTP classes that support https protocol through OS provided security layer. Unless you have other specific reasons to use Indy, it is easier to use RTL classes (or components) from System.Net namespace than using Indy and fiddling with OpenSSL

 

https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Net

Share this post


Link to post
1 hour ago, frankie1 said:

So there's the need to manipulate the web page elements within the application, wait for the info, and fetch it and manipulate it

Depending on a specific site, the actions could involve Javascript which you couldn't imitate with Delphi. Probably you should examine the option of controlled browser component; then you won't need network component at all

Edited by Fr0sT.Brutal

Share this post


Link to post

Thank you for your fast answers

 

@Dalija Prasnikar : i had take a look at what System.Net offers reading the embarcadero docs you posted. However i couldn't find an example to start with. Considering i have to log in to:

https://a.b.com/loginform.aspx 

username: user1

password: password1

please can you show me what code should i use to retrieve the 'hello user1' after the succesfull login?
 

procedure TForm1.Button1Click(Sender: TObject);
begin
	// login and get the greeting_message;
	ShowMessage(greeting_message);
end;

I still dont get how http requests from System.Net work for https

 

@Fr0sT.Brutal : i was thinking of that but wouldn't it a big overhead for the application on android in terms of ram?

Share this post


Link to post
7 minutes ago, frankie1 said:

i had take a look at what System.Net offers reading the embarcadero docs you posted. However i couldn't find an example to start with.

There are some examples here: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_an_HTTP_Client

    var
      Client: THTTPClient;
      Response: IHTTPResponse;
    begin
      Client := THTTPClient.Create;
      try
        Response := Client.Get('https://httpbin.org/get');
        ...
      finally
        Client.Free;
      end;
7 minutes ago, frankie1 said:

Considering i have to log in to:

https://a.b.com/loginform.aspx

username: user1

password: password1

please can you show me what code should i use to retrieve the 'hello user1' after the succesfull login?

 

This is not just https. Specific example would depend on what kind of request server expects and what kind of response it returns.

 

If the server uses REST architecture there is another set of classes work with REST https://docwiki.embarcadero.com/RADStudio/Sydney/en/Tutorial:_Using_the_REST_Client_Library_to_Access_REST-based_Web_Services

 

Share this post


Link to post
1 hour ago, frankie1 said:

 

@Fr0sT.Brutal : i was thinking of that but wouldn't it a big overhead for the application on android in terms of ram?

If a system can run Chrome, it can run almost everything.

Share this post


Link to post

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

×