Solved

WEB Authentication

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

16 Experts available now in Live!

Get 1:1 Help Now