PEAR::HTTP_REQUEST
| From: | Lassiege Hugo | Date: | Tue, 25 Jan 2005 09:50:30 +0000 |
| Subject: | PEAR::HTTP_REQUEST | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17145@lists.php.net to get a copy of this message | ||
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 :
Code:
<?php
// Inclusion des lib PEAR
// ---------------------
set_include_path(get_include_path() . ';source/lib/PEAR');
require_once 'Request.php';
// Fill login form et submit
$req =& new HTTP_Request("http://localweb/monsite/login.php");
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addPostData("login","login");
$req->addPostData("password","password");
$req->addPostData("submit","enter");
if (!PEAR::isError($req->sendRequest()))
{
$response1 = $req->getResponseBody();
// If the buffer contains "succes" I know that I am correctly logged so I can access
to special page.
if ( strstr ( $response1, "succes") != false )
{
// Print another page accessible if I am logged in
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->setURL('http://localweb/monsite/affichageNews.php');
$req->clearPostData();
$req->sendRequest();
$response1 = $req->getResponseBody();
}
}
else
{
$response1 = "";
}
echo $response1;
?>
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 ?
best regards
hugo