Solved

WEB Authentication

Posted on 2003-11-06
3
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

695 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