Пример #1
0
$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);
}
Пример #2
0
 $recipient = $signatureApi->GetRolesList($clientId);
 if ($recipient->status == "Ok") {
     //Get id of role which can sign
     for ($i = 0; $i < count($recipient->result->roles); $i++) {
         if ($recipient->result->roles[$i]->name == "Signer") {
             $roleId = $recipient->result->roles[$i]->id;
         }
     }
     //Add recipient to envelope
     $addRecipient = $signatureApi->AddSignatureEnvelopeRecipient($clientId, $envelop->result->envelope->id, $email, $name, $lastName, $roleId, null);
     if ($addRecipient->status == "Ok") {
         //Get recipient id
         $getRecipient = $signatureApi->GetSignatureEnvelopeRecipients($clientId, $envelop->result->envelope->id);
         if ($getRecipient->status == "Ok") {
             $recipientId = $getRecipient->result->recipients[0]->id;
             $getDocuments = $signatureApi->GetSignatureEnvelopeDocuments($clientId, $envelop->result->envelope->id);
             if ($getDocuments->status == "Ok") {
                 $webHook = new WebhookInfo();
                 if ($callbackUrl != "") {
                     $webHook->callbackUrl = $callbackUrl;
                 } else {
                     $webHook->callbackUrl = "";
                 }
                 $send = $signatureApi->SignatureEnvelopeSend($clientId, $envelop->result->envelope->id, $webHook);
                 if ($send->status == "Ok") {
                     $envelopeId = $envelop->result->envelope->id;
                     if ($basePath == "https://api.groupdocs.com/v2.0") {
                         $iframe = 'https://apps.groupdocs.com/signature2/signembed/' . $envelopeId . '/' . $recipientId;
                         //iframe to dev server
                     } elseif ($basePath == "https://dev-api.groupdocs.com/v2.0") {
                         $iframe = 'https://dev-apps.groupdocs.com/signature2/signembed/' . $envelopeId . '/' . $recipientId;
$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
$outFileStream = FileStream::fromHttp($downloadFolder, $name);
//Download file from GroupDocs.
$download = $storageApi->GetFile($clientId, $guid, $outFileStream);