(PHP Extension) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
<?php
include("chilkat.php");
$success = false;
$http = new CkHttp();
$http->put_KeepResponseBody(true);
$sb = new CkStringBuilder();
$success = $http->DownloadSb('https://chilkatsoft.com/testData/helloWorld.txt','utf-8',$sb);
$statusCode = $http->get_LastStatus();
if ($success == false) {
if ($statusCode == 0) {
// Unable to either send the request or get the response.
print $http->lastErrorText() . "\n";
}
else {
// We got a response, but the status code was not in the 200s
print 'Response status code: ' . $statusCode . "\n";
// Examine the response body.
print 'Response body:' . "\n";
print $http->lastResponseBody() . "\n";
}
print 'Download failed.' . "\n";
}
else {
print 'Download success, response status = ' . $statusCode . "\n";
print $sb->getAsString() . "\n";
}
?>
|