Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 18784 программиста и 1632 робота. Сейчас ищут 1760 программистов ...
Basic Authentication
Вернуться к: HTTP_Request
Basic Authentication
Basic Authentication – Authentication for protected websites
Basic Authentication is a challenge-response mechanism described in RFC 2617.
How to use Basic Authentication
Basic Authentication
The following example assumes that one wants to fetch a page /protected.html on the host example.com that is protected using Basic Authentication. The necessary username to pass the authentication is johndoe and the appendant password is foo.
<?php
require_once "HTTP/Request.php";
$req =& new HTTP_Request("http://example.com/protected.html");
$req->setBasicAuth("johndoe", "foo");
$response = $req->sendRequest();
if (PEAR::isError($response)) {
echo $response->getMessage();
} else {
echo $req->getResponseBody();
}
?>
Вернуться к: HTTP_Request