(PHP Extension) HTTP Basic Authentication Test
Demonstrates how to do HTTP basic authentication using Chilkat.
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
$http->put_BasicAuth(true);
$http->put_Login('foo');
$http->put_Password('bar');
// Let's say we want to download a file that is protected by HTTP Basic Authenication..
$success = $http->Download('https://www.example.com/someDir/document.pdf','qa_output/document.pdf');
if ($success == false) {
print $http->lastErrorText() . "\n";
exit;
}
print 'Success.' . "\n";
?>
|