PHP
Chilkat2 PHP
Example: Http.QuickGetStr method
Demonstrates theQuickGetStr method.
Chilkat PHP Downloads
<?php
use Chilkat2\Http;
$http = new Http();
// Keep the response body if there's an error.
$http->KeepResponseBody = true;
// Send the HTTP GET and return the content in a string.
try {
$str = $http->QuickGetStr('https://www.chilkatsoft.com/helloWorld.json');
} catch (\Chilkat2\Exception $e) {
if ($http->LastStatus == 0) {
// Communications error. We did not get a response.
echo $e->getMessage(), "\n";
} else {
echo 'Response status code: ', $http->LastStatus, "\n";
echo "Response body error text:\n";
echo $http->LastResponseBody, "\n";
}
exit;
}
echo $str, "\n";
echo "Success\n";