$error = 'Please enter all parameters'; F3::set('error', $error); } else { //path to settings file - temporary save userId and apiKey like to property file $infoFile = fopen(__DIR__ . '/../user_info.txt', 'w'); fwrite($infoFile, $clientId . "\r\n" . $privateKey . "\r\n" . $email); fclose($infoFile); F3::set('userId', $clientId); F3::set('privateKey', $privateKey); F3::set('email', $email); //###Create Signer, ApiClient and Storage Api objects //Create signer object $signer = new GroupDocsRequestSigner($privateKey); //Create apiClient object $apiClient = new APIClient($signer); $signatureApi = new SignatureApi($apiClient); //Set url to choose whot server to use if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } //Set base path $signatureApi->setBasePath($basePath); if (empty($callbackUrl)) { $callbackUrl = ""; } //Set variables for template F3::set("callbackUrl", $callbackUrl); //Create WebHook object $webHook = new WebhookInfo(); //Set callbackUrl url of webhook which will be triggered when form is signed.
$signer = new SignatureSignDocumentSignerSettingsInfo(); $signer->placeSignatureOn = 1; $signer->name = $fiSignature["name"]; $signer->data = "data:" . $fiSignature["type"] . ";base64," . base64_encode($signatureContent); $signer->height = 40; $signer->width = 100; $signer->top = 0.83319; $signer->left = 0.72171; $signer->email = "*****@*****.**"; //###Create Signer, ApiClient and Storage Api objects //Create signer object $signature = new GroupDocsRequestSigner($privateKey); //Create apiClient object $apiClient = new APIClient($signature); //Create Storage Api object $signatureApi = new SignatureApi($apiClient); //Create AsyncApi object $asyncApi = new AsyncApi($apiClient); //Check if user entered base path if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } //Set base path $signatureApi->setBasePath($basePath); $asyncApi->setBasePath($basePath); //Create setting variable for signature SignDocument method $settings = new SignatureSignDocumentSettingsInfo(); $settings->documents = array(get_object_vars($document)); $settings->signers = array(get_object_vars($signer)); //###Make a request to Signature Api for sign document
$guid = null; //Get raw data $json = file_get_contents("php://input"); //path to settings file - temporary save userId and apiKey like to property file //Decode json with raw data to array $callBack_data = json_decode($json, true); //Get job id from array $envelopeId = $callBack_data["SourceId"]; $jobStatus = $callBack_data["EventType"]; if ($jobStatus == "JobCompleted") { //Create signer object $signer = new GroupDocsRequestSigner(trim($privateKey)); //Create apiClient object $apiClient = new APIClient($signer); //Create AsyncApi object $signatureApi = new SignatureApi($apiClient); //Create Storage Api object $storageApi = new StorageApi($apiClient); $getDocInfo = $signatureApi->GetSignatureEnvelopeDocuments($clientId, $envelopeId); //path to settings file - temporary save userId and apiKey like to property file if ($getDocInfo->status == "Ok") { $guid = $getDocInfo->result->documents[0]->documentId; } //path to settings file - temporary save userId and apiKey like to property file if (file_exists(__DIR__ . '/../../callback_info.txt')) { unlink(__DIR__ . '/../../callback_info.txt'); } $infoFile = fopen(__DIR__ . '/../../callback_info.txt', 'w'); fwrite($infoFile, $guid); fclose($infoFile); }
} F3::set('userId', $clientId); F3::set('privateKey', $privateKey); //###Create Signer, ApiClient and Storage Api objects //Create signer object $signer = new GroupDocsRequestSigner($privateKey); //Create apiClient object $apiClient = new APIClient($signer); //Create Doc Api object $docApi = new DocApi($apiClient); //Create Storage Api object $apiStorage = new StorageApi($apiClient); //Create AsyncApi object $api = new AsyncApi($apiClient); $mergApi = new MergeApi($apiClient); $signatureApi = new SignatureApi($apiClient); //Set url to choose whot server to use if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } //Set base path $docApi->setBasePath($basePath); $apiStorage->setBasePath($basePath); $api->setBasePath($basePath); $mergApi->setBasePath($basePath); $signatureApi->setBasePath($basePath); //Get entered by user data $name = F3::get('POST["name"]'); $lastName = "lastName"; $email = F3::get('POST["email"]');
if (empty($clientId) || empty($privateKey)) { $error = 'Please enter all required parameters'; F3::set('error', $error); } else { //Deleting of tags, slashes and space from clientId and privateKey $clientId = strip_tags(stripslashes(trim($clientId))); //ClientId==UserId $apiKey = strip_tags(stripslashes(trim($privateKey))); //ApiKey==PrivateKey //###Create Signer, ApiClient and Storage Api objects //Create signer object $signer = new GroupDocsRequestSigner($apiKey); //Create apiClient object $apiClient = new APIClient($signer); //Create Storage Api object $signatureApi = new SignatureApi($apiClient); //Create Storage Api object $storageApi = new StorageApi($apiClient); //Create AsyncApi object $asyncApi = new AsyncApi($apiClient); $mergApi = new MergeApi($apiClient); $docApi = new DocApi($apiClient); //Check if user entered base path if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } //Build propper basePath if (substr($basePath, -3) != "2.0") { if (substr($basePath, -1) != "/") { $basePath = $basePath . "/v2.0";
} //###Create GroupDocs Api objects //Create signer object $signer = new GroupDocsRequestSigner($privateKey); //Create apiClient object $apiClient = new APIClient($signer); //Create Doc Api object $docApi = new DocApi($apiClient); //Create Storage Api object $storageApi = new StorageApi($apiClient); //Create AsyncApi object $AsyncApi = new AsyncApi($apiClient); //Create MergeApi object $mergApi = new MergeApi($apiClient); //Create SignatureApi object $signature = new SignatureApi($apiClient); //Set base path for all Apis $docApi->setBasePath($basePath); $storageApi->setBasePath($basePath); $AsyncApi->setBasePath($basePath); $mergApi->setBasePath($basePath); $signature->setBasePath($basePath); try { //File for upload $file = $_FILES['file']; //Temp name of the file $tmpName = $file['tmp_name']; //Original name of the file $name = $file['name']; //Create file stream $fs = FileStream::fromFile($tmpName);
if (!isset($clientId) || !isset($privateKey) || !isset($envelopeGuid)) { $error = 'Please enter all required parameters'; F3::set('error', $error); } else { //Clear entered data from tags and spaces $clientId = strip_tags(trim($clientId)); $privateKey = strip_tags(trim($privateKey)); $envelopeGuid = strip_tags(trim($envelopeGuid)); $basePath = F3::get('POST["basePath"]'); //###Create Signer, ApiClient and Storage Api objects //Create signer object $signer = new GroupDocsRequestSigner($privateKey); //Create apiClient object $apiClient = new APIClient($signer); //Create Storage Api object $signatureApi = new SignatureApi($apiClient); //Check if user entered base path if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } $basePath = strip_tags(trim($basePath)); //Set base path $signatureApi->setBasePath($basePath); //###Make a request to Storage API using clientId and file id try { //Local path to the downloads folder $downloadFolder = dirname(__FILE__) . '/../downloads'; //Check is folder exist if (!file_exists($downloadFolder)) { //If folder don't exist create it
//Original name of the file $name = $uploadedFile['name']; //Creat file stream $fs = FileStream::fromFile($tmpName); //###Make a request to Storage API using clientId //Upload file to current user storage try { $uploadResult = $storageApi->Upload($clientID, $name, 'uploaded', "", 0, $fs); //###Check if file uploaded successfully if ($uploadResult->status == "Ok") { //Get file GUID $fileGuId = $uploadResult->result->guid; //Get file name $name = $uploadResult->result->adj_name; //Create SignatureApi object $signature = new SignatureApi($apiClient); try { //Create envilope using user id and entered by user name $envelop = $signature->CreateSignatureEnvelope($clientID, $name); if ($envelop->status == "Ok") { sleep(5); //Add uploaded document to envelope $addDocument = $signature->AddSignatureEnvelopeDocument($clientID, $envelop->result->envelope->id, $fileGuId, null, true); try { if ($addDocument->status == "Ok") { try { //Get role list for current user $recipient = $signature->GetRolesList($clientID); if ($recipient->status == "Ok") { //Get id of role which can sign for ($i = 0; $i < count($recipient->result->roles); $i++) {
fwrite($infoFile, $clientId . "\r\n" . $privateKey); fclose($infoFile); //Delete temporary file which content callback data if (file_exists(__DIR__ . '/../callback_info.txt')) { unlink(__DIR__ . '/../callback_info.txt'); } //Set variables for template F3::set('userId', $clientId); F3::set('privateKey', $privateKey); //###Create Signer, ApiClient and Storage Api objects //Create signer object $signer = new GroupDocsRequestSigner($privateKey); //Create apiClient object $apiClient = new APIClient($signer); //Create Signature API object $signatureApi = new SignatureApi($apiClient); //Set url to choose whot server to use if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } //Set base path $signatureApi->setBasePath($basePath); //Check if callback URL is empty if (empty($callbackUrl)) { $callbackUrl = ""; } //Set variables for template F3::set("callbackUrl", $callbackUrl); //Create WebHook object $webHook = new WebhookInfo();
$userInfo = file(__DIR__ . '/../../user_info.txt'); //Get user data from text file $clientId = trim($userInfo[0]); $privateKey = trim($userInfo[1]); //Get raw data $json = file_get_contents("php://input"); //Decode json with raw data to array $callBack_data = json_decode($json, true); //Get job id from array $envelopeId = $callBack_data["SourceId"]; //Create signer object $signer = new GroupDocsRequestSigner(trim($privateKey)); //Create apiClient object $apiClient = new APIClient($signer); //Create AsyncApi object $signatureApi = new SignatureApi($apiClient); //Create Storage Api object $storageApi = new StorageApi($apiClient); $document = $signatureApi->GetSignatureEnvelopeDocuments($clientId, $envelopeId); if ($document->status == "Ok") { $guid = $document->result->documents[0]->documentId; $name = $document->result->documents[0]->name; } //Local path to the downloads folder $downloadFolder = dirname(__FILE__) . '/../../downloads'; //Check is folder exist if (!file_exists($downloadFolder)) { //If folder don't exist create it mkdir($downloadFolder); } //Obtaining file stream of downloading file and definition of folder where to download file
$clientId = trim($userInfo[0]); $privateKey = trim($userInfo[1]); //Get raw data from the GroupDocs server $json = file_get_contents("php://input"); //Decode json with raw data to array $callBack_data = json_decode($json, true); //Get job id from array $envelopeId = $callBack_data["SourceId"]; $jobStatus = $callBack_data["EventType"]; if ($jobStatus == "JobCompleted") { //Create signer object $signer = new GroupDocsRequestSigner(trim($privateKey)); //Create apiClient object $apiClient = new APIClient($signer); //Create Signature Api object $signatureApi = new SignatureApi($apiClient); //Create Storage Api object $storageApi = new StorageApi($apiClient); //Get signed document from the envelop $getDocInfo = $signatureApi->GetSignatureEnvelopeDocuments($clientId, $envelopeId); if ($getDocInfo->status == "Ok") { $name = $getDocInfo->result->documents[0]->name; //Local path to the downloads folder $downloadFolder = dirname(__FILE__) . '/../../downloads'; //Check is folder exist if (!file_exists($downloadFolder)) { //If folder don't exist create it mkdir($downloadFolder); } //Obtaining file stream of downloading file and definition of folder where to download file $outFileStream = FileStream::fromHttp($downloadFolder, $name);
$email = trim($userInfo[2]); $infoFile = fopen(__DIR__ . '/../../callback_info.txt', 'w'); fwrite($infoFile, $email); fclose($infoFile); //Get raw data $json = file_get_contents("php://input"); //Decode json with raw data to array $callBack_data = json_decode($json, true); //Get job id from array $formId = $callBack_data["SourceId"]; //Create signer object $signer = new GroupDocsRequestSigner(trim($privateKey)); //Create apiClient object $apiClient = new APIClient($signer); //Create AsyncApi object $signatureApi = new SignatureApi($apiClient); //Get document from signature form $getDocument = $signatureApi->GetSignatureFormDocuments($clientId, $formId); //Get document name $documentName = $getDocument->result->documents[0]->name; //Create email with document name $to = $email; $subject = "Reminder: An envelope has to be signed on GroupDocs"; $message = ' <html> <head> <title>Sign form notification</title> </head> <body> <p>Document' . $documentName . ' is signed</p> </body>
$guid = null; //Get raw data $json = file_get_contents("php://input"); //path to settings file - temporary save userId and apiKey like to property file //Decode json with raw data to array $callBack_data = json_decode($json, true); //Get job id from array $formId = $callBack_data["SourceId"]; $jobStatus = $callBack_data["EventType"]; $serializedData = json_decode($callBack_data['SerializedData'], true); $participant = $serializedData['ParticipantGuid']; if ($jobStatus == "JobCompleted") { //Create signer object $signer = new GroupDocsRequestSigner(trim($privateKey)); //Create apiClient object $apiClient = new APIClient($signer); //Create AsyncApi object $signatureApi = new SignatureApi($apiClient); //Create Storage Api object $storageApi = new StorageApi($apiClient); //Get document from envelop $getDocInfo = $signatureApi->GetSignatureFormParticipant($formId, $participant); if ($getDocInfo->status == "Ok") { //Get signed document GUID $guid = $getDocInfo->result->participant->signedDocuments[0]->documentGuid; } //path to settings file - temporary save signed document GUID like to property file $infoFile = fopen(__DIR__ . '/../../callback_info.txt', 'w'); fwrite($infoFile, $guid); fclose($infoFile); }