Solved

WEB Authentication

Posted on 2003-11-06
3
199 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now