Solved

WEB Authentication

Posted on 2003-11-06
3
202 Views
Last Modified: 2010-08-05
Hi !
I need to make a program where the user will enter the userid and the paassword and the program will Log in to a specific web site.
For Exemple, To access the internet I have to open my IE, type "http://www.veloxzone.com.br/vfile/pages/serviceLogon.jsp?service=internet_TERRA3"
and then manually enter my userid and password.
I want to make a program to do it automatically but I don't know wich component I can use and how to send this information to the web site. the address authetication is:
http://www.veloxzone.com.br/dashboard?fcn=serviceLogon&service=internet_TERRA3&username=XXXXXXXXpassword=XXXXXXX

Any help would be appreciated.
Rodrigo Lira.
PS: Sorry about my english.
0
Comment
Question by:lirageneve
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
EddieShipman earned 350 total points
ID: 9694051
Try this:
function TForm1.SendPostData(URL, AField1, AField2, AField3, AField4: String): TMemoryStream;
var
 Params: TStringStream;
begin
 Result := TMemoryStream.create;
 Params := TStringStream.create('');

 try
   with IdHTTP1 do
   begin
     Params.WriteString(URLEncode(AField1 + '&'));
     Params.WriteString(URLEncode(AField2));
     Params.WriteString(URLEncode(AField3));
     Params.WriteString(URLEncode(AField4));
     Request.ContentType := 'application/x-www-form-urlencoded';
     try
       Post(URL, Params, Result);
     except
       on E: Exception do
         showmessage('Error encountered during POST: ' + E.Message);
     end;
   end;
 Result.WriteBuffer(#0' ', 1);
 Result.Position := 0;
 except
   Params.Free;
 end;
end;

Usage:
SendPostData('http://www.veloxzone.com.br/dashboard',
             'fcn=serviceLogon',
             'service=internet_TERRA3',
             'username=XXXXXXXX',
             'password=XXXXXXX');

The result of calling the function can be saved, too:
procedure TForm1.btnLoginClick(Sender: TObject);
var
  HTMLStream: TMemoryStream;
begin
  HTMLStream := SendPostData('http://www.veloxzone.com.br/dashboard',
                             'fcn=serviceLogon',
                             'service=internet_TERRA3',
                             'username=XXXXXXXX',
                             'password=XXXXXXX');
  // Now save the result so we may open it in the browser or do ????
  HTMLStream.SaveToFile('c:\mysearch.htm');
  HTMLStream.Free;
end;
0
 

Author Comment

by:lirageneve
ID: 9698011
I think the code is ok, but I still dont know wich component I can use...
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9698483
Indy's  IdHTTP is the component. Included with Delphi6 and above, downloadable from
http://www.nevrona.com/indy for any other version.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mobile Keyboard covers the display of the TMemo 3 87
delphi parse string to params 3 122
Base1 Encode/Decode 3 77
scroll down TListBox component in Delphi 1 11
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question