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