Re: talking to a web page

From: Date: Wed, 03 Dec 2003 21:52:19 +0000
Subject: Re: talking to a web page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171730@lists.php.net to get a copy of this message
You can use PEAR's HTTP_Client package (http://pear.php.net/package/HTTP_Client) to connect to a website, do authentication, post forms, handle redirects, etc. It also keeps track of cookies. Here's a sample (note that the URLs in this will probably not work): require_once('HTTP/Client.php'); $client = &new HTTP_Client(array('user' => 'username', 'password' => 'password')); $code = $client->post('http://www.example.com/script.asp',
                      array('var1' = 'val1',
                            'VAR2' => 'val2'));
$code = $client->get('http://www.example.com/loginRequired.php'); David T-G wrote:
Hi, all -- My host has written a control panel to handle all site management needs, and it's great except that there's no back-end hook that I can use to create a new site or user once I have collected my input and verified my payment in my own pages. I obviously don't want to have to do all of the site creations by hand; that's why we have computers :-) At this point I could either figure out all of the steps for creating a site -- there are, to my knowledge so far, DB tables to update, dirs to make, other files to update, and apache to restart -- or figure out how to talk to the control panel from a script. With nearly fifteen years of SysAdmin background but only a few years of PHP background, I know which I think is probably easier or at least quicker :-) but I don't want to miss any little things that their interface does that will bite me in the tail later. The control panel requires authentication and a cookie and then a few clicks to get to the fill-ins, so I imagine that I could just construct that form and hand it off -- except for the login authentication part. Which route would y'all take, and (more importantly) which would you recommend to someone at my capable-but-not-expert level? Remember that I'll come back to the list when I get stumped ;-) TIA & HAND :-D


« previous php.general (#171730) next »