PHP
Chilkat2 PHP
Send a Bodyless REST Request into a StringBuilder
See more REST Examples
Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.
Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.
Chilkat PHP Downloads
<?php
use Chilkat2\Rest;
use Chilkat2\StringBuilder;
$rest = new Rest();
$bTls = true;
$bAutoReconnect = true;
try {
$rest->Connect('example.com', 443, $bTls, $bAutoReconnect);
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
$sbResponse = new StringBuilder();
$rest->FullRequestNoBodySb('GET', '/api/items/123', $sbResponse);
$responseText = $sbResponse->GetAsString();
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo $responseText, "\n";