(PHP ActiveX) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body. Note: This example requires Chilkat v11.0.0 or greater.
<?php
$success = 0;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new COM("Chilkat.Http");
$fac = new COM("Chilkat.FileAccess");
$reqBody = $fac->ReadEntireFile('qa_data/pdf/helloWorld.pdf');
$resp = new COM("Chilkat.HttpResponse");
$success = $http->HttpBinary('POST','https://example.com/something',$reqBody,'application/pdf',$resp);
if ($success == 0) {
print $http->LastErrorText . "\n";
exit;
}
$responseStatusCode = $resp->StatusCode;
print 'Status code: ' . $responseStatusCode . "\n";
// For example, if the response is XML, JSON, HTML, etc.
print 'response body:' . "\n";
print $resp->BodyStr . "\n";
?>
|