Re: PEAR::HTTP_REQUEST -> HTTP_CLIENT
| From: | hugo | Date: | Thu, 27 Jan 2005 20:05:18 +0000 |
| Subject: | Re: PEAR::HTTP_REQUEST -> HTTP_CLIENT | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17222@lists.php.net to get a copy of this message | ||
As I said in the first message below, I tried to navigate on my website with
Http_request and Justin answer me that I have to use Http_client. So I
tested like this :
<?php
// Inclusion des lib PEAR
// ---------------------
set_include_path(get_include_path() . ';source/lib/PEAR');
require_once 'Client.php';
$client =& new HTTP_Client();
$arrayParam ["login"] = "test";
$arrayParam ["pwd"] = "test";
$arrayParam ["submit"] = "enter";
PEAR::setErrorHandling (PEAR_ERROR_PRINT);
$res = $client->post ( http://localweb/login.php,
$arrayParam);
$response1 ="init1 </BR>";
$response2 ="init2 </BR>";
if (!PEAR::isError($res))
{
$response1 = $client->currentResponse();
$bodyresponse1 = $response1['body'];
echo $bodyresponse1;
// If I find the strings "bla bla" I know that I am connected.
if ( strstr ( $bodyresponse1, "bla bla") != false )
{
$res = $client->get(http://localweb/printNewsAdmin.php);
if (!PEAR::isError($res))
{
$response2 = $client->currentResponse();
$bodyresponse2 = $response2['body'];
echo $bodyresponse2;
}
else
{
$response2="Failed after 2nd request </BR>";
echo $res->getDebugInfo();
echo $res->getMessage();
}
}
else
{
$response2="Failed after strstr </BR>";
}
}
else
{
$response1 = "Failed after 1st request </BR>";
}
echo $response1;
echo $response2;
?>
And I get "Failed after 2nd request "
I don't know how to keep cookies et session variable.
Any idea ?
----- Original Message -----
From: "Justin Patrin" <papercrane@gmail.com>
To: "Lassiege Hugo" <hlassiege@sopragroup.com>
Cc: <pear-general@lists.php.net>
Sent: Tuesday, January 25, 2005 5:12 PM
Subject: Re: [PEAR] PEAR::HTTP_REQUEST
> On Tue, 25 Jan 2005 10:50:30 +0100, Lassiege Hugo
> <hlassiege@sopragroup.com> wrote:
> > Hi,
> > This is the first time I use this mailing list so I hope that I didn't
make a mistake.
> >
> > I try to made test with HTTP_REQUEST package yesterday. I am connecting
to my own website and then I verify that I am correctly logged in. If it's
correct, I try to print a page.
> > I use to following code :
> >
> [snip]
> > But it doesn't keep session variable and the second request
(HTTP_REQUEST_METHOD_GET) give me the loggin screen because the
authentification failed.
> >
> > Is it possible to keep session variable and to navigate into my website
like this ?
> >
>
> HTTP_Request only makes *single* requests, it's not set up to keep
> state information (aka cookies). HTTP_Client, which uses HTTP_Request,
> will do this.
>
> --
> Justin Patrin
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>