Protect Documents (PHP REST)

Skip to end of metadata
Go to start of metadata
This example allows you to protect a document using Saaspose.Words REST API in your PHP applications.
Input document should be uploaded at Saaspose storage before running this example.

We're referring to the following common methods to perform general operations:

SaasposeApp::$AppSID  = "77*****************";
SaasposeApp::$AppKey = "89************8";
SaasposeApp::$OutPutLocation = getcwd() . "\\Output\\";

$inputDocument = "MainDocument.doc";
$password = "abc";
$protectionType = "AllowOnlyComments";

$fieldsArray = array('Password'=>$password, 'ProtectionType'=>$protectionType);
//Build JSON to post
$json = json_encode($fieldsArray);

//build URI
$strURI = '' . $inputDocument . '/protection'; 

//sign URI
$signedURI = Utils::Sign($strURI);

Utils::processCommand($signedURI, "PUT", "json", $json);

//build URI to download output file 
$strURI = ''. $inputDocument;
//sign URI
$signedURI = Utils::Sign($strURI);

$responseStream = Utils::processCommand($signedURI, "GET", "", "");
//save output file
$outputFile = SaasposeApp::$OutPutLocation . $inputDocument;
Utils::saveFile($responseStream, $outputFile);
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.