PHP ActiveX
PHP ActiveX
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 ActiveX Downloads
<?php
$success = 0;
$rest = new COM("Chilkat.Rest");
$bTls = 1;
$bAutoReconnect = 1;
$success = $rest->Connect('example.com',443,$bTls,$bAutoReconnect);
if ($success == 0) {
print $rest->LastErrorText . "\n";
exit;
}
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
$sbResponse = new COM("Chilkat.StringBuilder");
$success = $rest->FullRequestNoBodySb('GET','/api/items/123',$sbResponse);
if ($success == 0) {
print $rest->LastErrorText . "\n";
exit;
}
$responseText = $sbResponse->getAsString();
if ($sbResponse->LastMethodSuccess == 0) {
print $sbResponse->LastErrorText . "\n";
exit;
}
print $responseText . "\n";
?>