Example #1
0
 //check if Downloads folder exists and remove it to clean all old files
 $callbackUrl = F3::get('POST["callbackUrl"]');
 if ($callbackUrl != "") {
     if (file_exists(__DIR__ . '/../downloads')) {
         delFolder(__DIR__ . '/../downloads/');
     }
 }
 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);
Example #2
0
             foreach ($files->result->files as $item) {
                 if ($item->guid == $fileId) {
                     $name = $item->name;
                     $guid = $item->id;
                 }
             }
         } else {
             throw new Exception($files->error_message);
         }
     } catch (Exception $e) {
         $error = 'ERROR: ' . $e->getMessage() . "\n";
         F3::set('error', $error);
     }
 }
 //###Create DocApi object
 $docApi = new DocApi($apiClient);
 $docApi->setBasePath($basePath);
 //Make request to user storage for sharing document
 try {
     $share = $docApi->ShareDocument($clientId, $guid, $sharer);
     if ($share->status == "Ok") {
         //If request was successfull - set shared variable for template
         F3::set('shared', $sharer['0']);
         F3::set('fileId', $guid);
     } else {
         throw new Exception($share->error_message);
     }
 } catch (Exception $e) {
     $error = 'ERROR: ' . $e->getMessage() . "\n";
     F3::set('error', $error);
 }
Example #3
0
 if (empty($clientId) || empty($privateKey)) {
     $error = 'Please enter all required parameters';
     F3::set('error', $error);
 } else {
     //Deleting all 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 docApi object
     $docApi = new DocApi($apiClient);
     //Create Storage Api object
     $storageApi = new StorageApi($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";
         } else {
             $basePath = $basePath . "v2.0";
         }
     }
Example #4
0
     $newPath = implode("/", $array);
 } else {
     $lastFolder = array_pop($array);
 }
 // initialization some variables
 $folderId = null;
 $users = "";
 //### Create Signer, ApiClient, StorageApi and Document Api objects
 // Create signer object
 $signer = new GroupDocsRequestSigner($privateKey);
 // Create apiClient object
 $apiClient = new ApiClient($signer);
 // Create Storage object
 $storageApi = new StorageApi($apiClient);
 // Create Document object
 $docApi = new DocApi($apiClient);
 if ($basePath == "") {
     //If base base is empty seting base path to prod server
     $basePath = 'https://api.groupdocs.com/v2.0';
 }
 //Set base path
 $storageApi->setBasePath($basePath);
 $docApi->setBasePath($basePath);
 // get folder ID
 try {
     $list = $storageApi->ListEntities($clientId, $newPath);
     if ($list->status == "Ok") {
         foreach ($list->result->folders as $folder) {
             if ($folder->name == $lastFolder) {
                 $folderId = $folder->id;
                 break;
Example #5
0
$privateKey = F3::get('POST["privateKey"]');
$basePath = F3::get('POST["basePath"]');
try {
    //###Check if user entered all parameters
    if (empty($clientId) || empty($privateKey)) {
        throw new Exception('Please enter FILE ID');
    } else {
        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
        $api = new DocApi($apiClient);
        //Create Storage Api object
        $storageApi = new StorageApi($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
        $api->setBasePath($basePath);
        $storageApi->setBasePath($basePath);
        //Get entered by user data
        $url = F3::get('POST["url"]');
        $file = $_FILES['file'];
        $fileId = F3::get('POST["fileId"]');
        $fileGuId = "";
Example #6
0
$privateKey = F3::get('POST["privateKey"]');
$fileId = F3::get('POST["fileId"]');
//###Check clientId, privateKey and file Id
if (!isset($clientId) || !isset($privateKey) || !isset($fileId)) {
    $error = 'Please enter all required parameters';
    F3::set('error', $error);
} else {
    $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
    $storageApi = new StorageApi($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';
    }
    //Set base path
    $storageApi->setBasePath($basePath);
    $docApi->setBasePath($basePath);
    //###Make a request to Doc API using clientId and file id
    //Obtaining all Metadata for file
    try {
        $docInfo = $docApi->GetDocumentMetadata($clientId, $fileId);
        //Selecting file names
        if ($docInfo->status == "Ok") {
            //Obtaining file name for entered file Id
Example #7
0
    $error = 'Please enter all required parameters';
    F3::set('error', $error);
} else {
    //Get base path
    $basePath = F3::get('POST["basePath"]');
    F3::set('userId', $clientId);
    F3::set('privateKey', $privateKey);
    // initialization some variables
    $views = 0;
    //### Create Signer, ApiClient and Document Api objects
    // Create signer object
    $signer = new GroupDocsRequestSigner($privateKey);
    // Create apiClient object
    $apiClient = new ApiClient($signer);
    // Create Document object
    $docApi = new DocApi($apiClient);
    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);
    // Make a request to Doc API using clientId
    try {
        $result = $docApi->GetDocumentViews($clientId);
        if ($result->status == "Ok") {
            // Check the result of the request
            if (isset($result->result)) {
                // If request was successfull - set annotations variable for template
                F3::set('views', count($result->result->views));
            }
Example #8
0
 $fileGuId = "";
 $url = F3::get('POST["url"]');
 $file = $_FILES['file'];
 $fileId = F3::get('POST["fileId"]');
 //Get base path
 $basePath = F3::get('POST["basePath"]');
 //Set variables for Viewer
 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 DocApi object
 $docApi = new DocApi($apiClient);
 //Create Storage Api object
 $storageApi = new StorageApi($apiClient);
 //Check is 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
 $docApi->setBasePath($basePath);
 $storageApi->setBasePath($basePath);
 //Check if user choose upload file from URL
 if ($url != "") {
     //Upload file from URL
     try {
         $uploadResult = $storageApi->UploadWeb($clientId, $url);