예제 #1
0
 //Set array feilds array to the Datasourc
 $dataSource->fields = $array;
 //Add Datasource to GroupDocs
 $addDataSource = $mergApi->AddDataSource($clientId, $dataSource);
 //Check status
 if ($addDataSource->status == "Ok") {
     //If status ok merge Datasource to new pdf file
     $job = $mergApi->MergeDatasource($clientId, $templateGuid, $addDataSource->result->datasource_id, "pdf", null);
     //Check status
     if ($job->status == "Ok") {
         //### Check job status
         for ($n = 0; $n <= 5; $n++) {
             //Delay necessary that the inquiry would manage to be processed
             sleep(2);
             //Make request to api for get document info by job id
             $jobInfo = $api->GetJobDocuments($clientId, $job->result->job_id);
             //Check job status, if status is Completed or Archived exit from cycle
             if ($jobInfo->result->job_status == "Completed" || $jobInfo->result->job_status == "Archived") {
                 break;
                 //If job status Postponed throw exception with error
             } elseif ($jobInfo->result->job_status == "Postponed") {
                 throw new Exception("Job is failed");
             }
         }
         if ($jobInfo->result->job_status == "Pending") {
             throw new Exception("Job is pending");
         }
         //Get file guid
         $guid = $jobInfo->result->inputs[0]->outputs[0]->guid;
         $envelop = $signatureApi->CreateSignatureEnvelope($clientId, $jobInfo->result->inputs[0]->outputs[0]->name);
         if ($envelop->status == "Ok") {
예제 #2
0
 //     $json = file_get_contents("php://input"); - get callbackUrl data
 //     $fp = fopen(__DIR__ . '/../../temp/signature_request_log.txt', 'a'); - open file for data write
 //     fwrite($fp, $json . "\r\n"); - write data to the file
 //     fclose($fp); - close file
 //Check request status
 if ($info->status == "Ok") {
     //Create AsyncApi object
     $asyncApi = new AsyncApi($apiClient);
     $asyncApi->setBasePath($basePath);
     //### Check job status
     for ($i = 0; $i <= 5; $i++) {
         //Delay necessary that the inquiry would manage to be processed
         sleep(3);
         //Make request to api for get document info by job id
         try {
             $jobInfo = $asyncApi->GetJobDocuments($clientId, $info->result->job_id);
             if ($jobInfo->status == "Ok") {
                 //Check job status, if status is Completed or Archived exit from cycle
                 if ($jobInfo->result->job_status == "Completed" || $jobInfo->result->job_status == "Archived") {
                     break;
                     //If job status Postponed throw exception with error
                 } elseif ($jobInfo->result->job_status == "Postponed") {
                     throw new Exception('Job is failure');
                 }
             } else {
                 throw new Exception($jobInfo->error_message);
             }
         } catch (Exception $e) {
             $error = 'ERROR: ' . $e->getMessage() . "\n";
             F3::set('error', $error);
         }
예제 #3
0
$json = file_get_contents("php://input");
//Decode json with raw data to array
$callBack_data = json_decode($json, true);
//Get job id from array
$jobId = $callBack_data["SourceId"];
//Create signer object
$signer = new GroupDocsRequestSigner(trim($privateKey));
//Create apiClient object
$apiClient = new APIClient($signer);
//Create AsyncApi object
$asyncApi = new AsyncApi($apiClient);
//Create Storage Api object
$storageApi = new StorageApi($apiClient);
sleep(5);
//Make request to Async API to get job info
$jobInfo = $asyncApi->GetJobDocuments(trim($clientId), $jobId, "");
if ($jobInfo->status == "Ok") {
    //Get file guid
    $guid = $jobInfo->result->inputs[0]->outputs[0]->guid;
    //Get file name
    $name = $jobInfo->result->inputs[0]->outputs[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);
예제 #4
0
     }
 } catch (Exception $e) {
     $error = 'ERROR: ' . $e->getMessage() . "\n";
     F3::set('error', $error);
 }
 try {
     //Change job status
     $jobInfo->status = 0;
     //Update job with new status
     $updateJob = $asyncApi->UpdateJob($clientID, $createJob->result->job_id, $jobInfo);
     if ($updateJob->status == "Ok") {
         try {
             //Delay for server proccesing
             sleep(8);
             //Get result document guid from job
             $getJobDocument = $asyncApi->GetJobDocuments($clientID, $createJob->result->job_id);
             if ($getJobDocument->status == "Ok") {
                 //Generate iframe url
                 if ($basePath == "https://api.groupdocs.com/v2.0") {
                     $iframe = 'https://apps.groupdocs.com/document-viewer/embed/' . $getJobDocument->result->inputs[0]->outputs[0]->guid;
                     //iframe to dev server
                 } elseif ($basePath == "https://dev-api.groupdocs.com/v2.0") {
                     $iframe = 'https://dev-apps.groupdocs.com/document-viewer/embed/' . $getJobDocument->result->inputs[0]->outputs[0]->guid;
                     //iframe to test server
                 } elseif ($basePath == "https://stage-api-groupdocs.dynabic.com/v2.0") {
                     $iframe = 'https://stage-apps-groupdocs.dynabic.com/document-viewer/embed/' . $getJobDocument->result->inputs[0]->outputs[0]->guid;
                 } elseif ($basePath == "http://realtime-api.groupdocs.com") {
                     $iframe = 'https://relatime-apps.groupdocs.com/document-viewer/embed/' . $getJobDocument->result->inputs[0]->outputs[0]->guid;
                 }
                 $iframe = $signer->signUrl($iframe);
                 F3::set('url', $iframe);
예제 #5
0
 if ($fileId != "") {
     //Get entered by user file GUID
     $fileGuId = $fileId;
 }
 F3::set("callbackUrl", $callbackUrl);
 //Make request to api for convert file
 try {
     $convert = $asyncApi->Convert($clientId, $fileGuId, null, null, null, $callbackUrl, $convertType);
     //Check request status
     if ($convert->status == "Ok") {
         //Delay necessary that the inquiry would manage to be processed
         for ($i = 0; $i < 5; $i++) {
             sleep(5);
             try {
                 //Make request to api for get document info by job id
                 $jobInfo = $asyncApi->GetJobDocuments($clientId, $convert->result->job_id, "");
                 $guid = '';
                 if ($jobInfo->result->job_status == "Archived") {
                     if ($jobInfo->result->inputs[0]->outputs[0]->guid != "") {
                         //Get file guid
                         $guid = $jobInfo->result->inputs[0]->outputs[0]->guid;
                         break;
                     } else {
                         throw new Exception($jobInfo->error_message);
                     }
                 } else {
                     continue;
                 }
             } catch (Exception $e) {
                 $error = 'ERROR: ' . $e->getMessage() . "\n";
                 F3::set('error', $error);