Basic 認証

Basic 認証 – 保護された Web サイトのための認証

Basic 認証導入

Basic 認証は、RFC 2617 で定義されたチャレンジ-レスポンスメカニズムです。

Basic 認証の使用方法

Basic 認証

以下の例は、Basic 認証で保護されたホスト example.com にあるとあるページ /protected.html を取得しようとしている、と想定しています。 認証をパスするために必要なユーザー名は johndoe で、 付随するパスワードは 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 導入 (Previous) HTTP_Request でクッキーを利用する (Next)
Last updated: Fri, 25 May 2012 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.