├── document-apis ├── sample_documents │ ├── OfferLetter.zdoc │ ├── MS_Word_Document_v0.docx │ ├── MS_Word_Document_v1.docx │ ├── Graphic-Design-Proposal.docx │ └── candidates.json ├── run.php ├── PreviewDocument.php ├── MergeAndDownload.php ├── GetMergeFields.php ├── WatermarkDocument.php ├── CompareDocument.php ├── ConvertDocument.php ├── MergeAndDeliver.php ├── DeleteDocument.php ├── DeleteDocumentSession.php ├── EditDocument.php ├── GetDocumentDetails.php └── GetSessionDetails.php ├── presentation-apis ├── sample_documents │ └── Zoho_Show.pptx ├── run.php ├── ConvertPresentation.php ├── PreviewPresentation.php ├── DeletePresentation.php ├── DeletePresentationSession.php ├── CreatePresentation.php └── EditPresentation.php ├── spreadsheet-apis ├── sample_documents │ └── Contact_List.xlsx ├── run.php ├── ConvertSpreadsheet.php ├── PreviewSpreadsheet.php ├── DeleteSpreadsheet.php ├── DeleteSpreadsheetSession.php ├── CreateSpreadsheet.php ├── EditSpreadsheet.php └── GetSessionDetails.php ├── composer.json ├── .gitignore ├── pdf-apis ├── run.php ├── DeletePdf.php ├── DeletePdfSession.php ├── GetPdfSessionDetails.php ├── EditPdf.php └── GetPdfDocumentDetails.php ├── save_callback_implementation ├── README.md └── save_callback.php ├── README.md ├── Initialize.php └── GetPlanDetails.php /document-apis/sample_documents/OfferLetter.zdoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoho/office-integrator-php-sdk-examples/main/document-apis/sample_documents/OfferLetter.zdoc -------------------------------------------------------------------------------- /presentation-apis/sample_documents/Zoho_Show.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoho/office-integrator-php-sdk-examples/main/presentation-apis/sample_documents/Zoho_Show.pptx -------------------------------------------------------------------------------- /spreadsheet-apis/sample_documents/Contact_List.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoho/office-integrator-php-sdk-examples/main/spreadsheet-apis/sample_documents/Contact_List.xlsx -------------------------------------------------------------------------------- /document-apis/sample_documents/MS_Word_Document_v0.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoho/office-integrator-php-sdk-examples/main/document-apis/sample_documents/MS_Word_Document_v0.docx -------------------------------------------------------------------------------- /document-apis/sample_documents/MS_Word_Document_v1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoho/office-integrator-php-sdk-examples/main/document-apis/sample_documents/MS_Word_Document_v1.docx -------------------------------------------------------------------------------- /document-apis/sample_documents/Graphic-Design-Proposal.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoho/office-integrator-php-sdk-examples/main/document-apis/sample_documents/Graphic-Design-Proposal.docx -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zohocorporation/office-integrator-sdk-examples", 3 | "authors": [ 4 | { 5 | "name": "prabakaran.r", 6 | "email": "prabakaran.r@zohocorp.com" 7 | } 8 | ], 9 | "autoload": { 10 | "psr-4": { 11 | "": "src/" 12 | } 13 | }, 14 | "require": { 15 | "zohocorporation/office-integrator-sdk": "*" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | composer.phar 2 | composer.lock 3 | /vendor/ 4 | .idea 5 | 6 | app.log 7 | sdk_tokens.txt 8 | 9 | ### VS Code ### 10 | .vscode/ 11 | 12 | 13 | # OS generated files # 14 | ###################### 15 | .DS_Store 16 | .DS_Store? 17 | ._* 18 | .Spotlight-V100 19 | .Trashes 20 | ehthumbs.db 21 | Thumbs.db 22 | *.swp 23 | *.swo 24 | *.orig 25 | dump.rdb 26 | 27 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control 28 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file 29 | # composer.lock 30 | 31 | 32 | -------------------------------------------------------------------------------- /pdf-apis/run.php: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /document-apis/run.php: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /presentation-apis/run.php: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /spreadsheet-apis/run.php: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /document-apis/sample_documents/candidates.json: -------------------------------------------------------------------------------- 1 | { 2 | "fields":[ 3 | 4 | {"id":"FirstName","display_name":"First Name","type":"String"}, 5 | {"id":"LastName","display_name":"Last Name","type":"String"}, 6 | {"id":"Company","display_name":"Company","type":"String"}, 7 | {"id":"Salary","display_name":"Salary","type":"String"}, 8 | {"id":"jobTitle","display_name":"jobTitle","type":"String"}, 9 | {"id":"Location","display_name":"Location","type":"String"}, 10 | {"id":"Address Line 1","display_name":"Address Line 1","type":"String"}, 11 | {"id":"Address Line 2","display_name":"Address Line 2","type":"String"}, 12 | {"id":"zipCode","display_name":"zipCode","type":"String"} 13 | ], 14 | "data":[ 15 | { 16 | "FirstName":"Romin","LastName":"Irani","Company":"Zylker Corp","Salary":"20000","Location":"Pleasonton","Address Line 1":"4665 Bernal Ave.","Address Line 2":"Pleasanton, CA","zipCode":"CA 408-1234567"}, 17 | { 18 | "FirstName":"Neil","LastName":"Stephen","Company":"Zylker Corp","Salary":"10000","Location":"Pleasonton","Address Line 1":"4665 Bernal Ave.","Address Line 2":"New York","zipCode":"NY 94566-7498"}, 19 | { 20 | "FirstName":"Tom","LastName":"Hanks","Company":"Zylker Corp","Salary":"50000","Location":"Pleasonton","Address Line 1":"4665 Bernal Ave.","Address Line 2":"Washington","zipCode":"WT 94566-7498"} 21 | ] 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /save_callback_implementation/README.md: -------------------------------------------------------------------------------- 1 | Save the [code](https://github.com/iampraba/zoi-php-sdk-examples/blob/main/save_callback_implementation/save_callback.php) in a file, for example, save_callback.php. 2 | 3 | To run this code from your Mac terminal, you can use the built-in PHP development server. Open the terminal, navigate to the directory where save_callback.php is saved, and run the following command: 4 | 5 | ``` sh 6 | php -S localhost:8000 7 | ``` 8 | 9 | This will start the PHP development server, and you can access the API endpoint at http://localhost:8000/save_callback.php. 10 | 11 | Test above api end point and verify if the file store without any error. You could free to edit the code to fit your application needs. 12 | 13 | To host this code on a server so that it can be accessed from the internet, you would need a web server with PHP support. Here are the general steps: 14 | 15 | - Choose a hosting provider or set up your own server with a web server software like Apache or Nginx. 16 | - Upload the upload.php file to your server. 17 | - Make sure the server has PHP installed and properly configured. 18 | - Ensure that the destination folder for uploaded files has appropriate write permissions. 19 | - Access the API endpoint using the server's domain or IP address, e.g., http://example.com/save_callback.php. 20 | 21 | Note that the exact steps may vary depending on your hosting environment and configuration. It's recommended to refer to the documentation provided by your hosting provider or the server software you choose for more detailed instructions. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zoho Office Integrator - PHP SDK Example Codes 2 | 3 | 4 | ## Getting Started 5 | 6 | Zoho Office Integrator PHP SDK used to help you quickly integrator Zoho Office Integrator editors in side your web application. This repository will example code to integrate Zoho Office Integrator using PHP SDK. 7 | 8 | ## How to run the example codes 9 | 10 | - Clone this repository in your local machine. 11 | ```sh 12 | git clone https://github.com/zoho/office-integrator-php-sdk-examples.git 13 | ``` 14 | 15 | - Install [**Office Integrator PHP SDK**](https://packagist.org/packages/zohocorporation/office-integrator-sdk) and other dependencies 16 | - Navigate to the folder **office-integrator-php-sdk-examples** 17 | ```sh 18 | cd office-integrator-php-sdk-examples 19 | ``` 20 | 21 | - Run the command below. This command will install office integrator php sdk and it's dependencies. 22 | ```sh 23 | composer install 24 | ``` 25 | 26 | - Now go to any of the folder document-apis 27 | ```sh 28 | cd document-apis 29 | ``` 30 | 31 | - Run any of the example files in those folders. 32 | ```sh 33 | php CreateDocument.php 34 | ``` 35 | - You can make the changes in any of the example code and test if your changes get reflected in the output. 36 | 37 | - Check the [documentation page](https://www.zoho.com/officeplatform/integrator/api/v1/) for all possible customizations. 38 | 39 | ## License 40 | 41 | This SDK is distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), see LICENSE.txt for more information. 42 | -------------------------------------------------------------------------------- /save_callback_implementation/save_callback.php: -------------------------------------------------------------------------------- 1 | 'success', 25 | 'message' => 'File uploaded successfully.' 26 | ]; 27 | } else { 28 | // Return error response 29 | $response = [ 30 | 'status' => 'error', 31 | 'message' => 'No file uploaded or an error occurred.' 32 | ]; 33 | } 34 | 35 | // Send the response as JSON 36 | header('Content-Type: application/json'); 37 | echo json_encode($response); 38 | } else { 39 | // Handle unsupported HTTP methods 40 | header('HTTP/1.1 405 Method Not Allowed'); 41 | header('Allow: POST'); 42 | echo 'Method Not Allowed'; 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /Initialize.php: -------------------------------------------------------------------------------- 1 | addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 24 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 25 | $tokens = [ $authBuilder->build() ]; 26 | 27 | # Configure a proper file path to write the sdk logs 28 | $logger = (new LogBuilder()) 29 | ->level(Levels::INFO) 30 | ->filePath("./app.log") 31 | ->build(); 32 | 33 | (new InitializeBuilder()) 34 | ->environment($environment) 35 | ->tokens($tokens) 36 | ->logger($logger) 37 | ->initialize(); 38 | 39 | echo "SDK initialized successfully.\n"; 40 | } 41 | } 42 | 43 | Initialize::initializeSdk(); -------------------------------------------------------------------------------- /GetPlanDetails.php: -------------------------------------------------------------------------------- 1 | getPlanDetails(); 31 | 32 | if ($responseObject != null) { 33 | // Get the status code from response 34 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 35 | 36 | // Get the api response object from responseObject 37 | $responseObject = $responseObject->getObject(); 38 | 39 | if ($responseObject != null) { 40 | // Check if the expected PlanDetails instance is received 41 | if ($responseObject instanceof PlanDetails) { 42 | echo "\nPlan name : - " . $responseObject->getPlanName() . "\n"; 43 | echo "\nAPI usage limit : - " . $responseObject->getUsageLimit() . "\n"; 44 | echo "\nAPI usage so far : - " . $responseObject->getTotalUsage() . "\n"; 45 | echo "\nPlan upgrade payment link : - " . $responseObject->getPaymentLink() . "\n"; 46 | echo "\nSubscription period : - " . $responseObject->getSubscriptionPeriod() . "\n"; 47 | echo "\nSubscription interval : - " . $responseObject->getSubscriptionInterval() . "\n"; 48 | } elseif ($responseObject instanceof InvalidConfigurationException) { 49 | echo "\nInvalid configuration exception." . "\n"; 50 | echo "\nError Code - " . $responseObject->getCode() . "\n"; 51 | echo "\nError Message - " . $responseObject->getMessage() . "\n"; 52 | if ( $responseObject->getKeyName() ) { 53 | echo "\nError Key Name - " . $responseObject->getKeyName() . "\n"; 54 | } 55 | if ( $responseObject->getParameterName() ) { 56 | echo "\nError Parameter Name - " . $responseObject->getParameterName() . "\n"; 57 | } 58 | } else { 59 | echo "\nRequest not completed successfully\n"; 60 | } 61 | } 62 | } 63 | } catch (Exception $error) { 64 | echo "\nException while running sample code: " . $error . "\n"; 65 | } 66 | } 67 | 68 | public static function initializeSdk() { 69 | 70 | # Update the api domain based on in which data center user register your apikey 71 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 72 | $environment = new Production("https://api.office-integrator.com"); 73 | # User your apikey that you have in office integrator dashboard 74 | //Update this apikey with your own apikey signed up in office inetgrator service 75 | $authBuilder = new AuthBuilder(); 76 | $authentication = new Authentication(); 77 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 78 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 79 | $tokens = [ $authBuilder->build() ]; 80 | 81 | # Configure a proper file path to write the sdk logs 82 | $logger = (new LogBuilder()) 83 | ->level(Levels::INFO) 84 | ->filePath("./app.log") 85 | ->build(); 86 | 87 | (new InitializeBuilder()) 88 | ->environment($environment) 89 | ->tokens($tokens) 90 | ->logger($logger) 91 | ->initialize(); 92 | 93 | echo "SDK initialized successfully.\n"; 94 | } 95 | } 96 | 97 | GetPlanDetails::execute(); 98 | 99 | -------------------------------------------------------------------------------- /document-apis/PreviewDocument.php: -------------------------------------------------------------------------------- 1 | setUrl("https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx"); 33 | 34 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 35 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Graphic-Design-Proposal.docx"; 36 | // $previewParameters->setDocument(new StreamWrapper(null, null, $filePath)); 37 | 38 | $previewDocumentInfo = new PreviewDocumentInfo(); 39 | 40 | //Time value used to generate unique document everytime. You can replace based on your application. 41 | $previewDocumentInfo->setDocumentName("Graphic-Design-Proposal.docx"); 42 | 43 | $previewParameters->setDocumentInfo($previewDocumentInfo); 44 | 45 | $permissions = array(); 46 | 47 | //SDK-ERROR: Array value not sent properly 48 | $permissions["document.print"] = false; 49 | 50 | $previewParameters->setPermissions($permissions); 51 | 52 | $responseObject = $sdkOperations->createDocumentPreview($previewParameters); 53 | 54 | if ($responseObject != null) { 55 | //Get the status code from response 56 | echo "\nStatus Code: " . $responseObject->getStatusCode(); 57 | 58 | //Get the api response object from responseObject 59 | $writerResponseObject = $responseObject->getObject(); 60 | 61 | if ($writerResponseObject != null) { 62 | //Check if expected PreviewResponse instance is received 63 | if ($writerResponseObject instanceof PreviewResponse) { 64 | echo "\nDocument ID - " . $writerResponseObject->getDocumentId(); 65 | echo "\nDocument session ID - " . $writerResponseObject->getSessionId(); 66 | echo "\nDocument preview URL - " . $writerResponseObject->getPreviewUrl(); 67 | echo "\nDocument delete URL - " . $writerResponseObject->getDocumentDeleteUrl(); 68 | echo "\nDocument session delete URL - " . $writerResponseObject->getSessionDeleteUrl(); 69 | } else if ($writerResponseObject instanceof InvalidConfigurationException) { 70 | echo "\nInvalid configuration exception. Exception json - " . $writerResponseObject->getMessage(); 71 | } else { 72 | echo "\nRequest not completed successfully"; 73 | } 74 | } 75 | } 76 | } catch (\Exception $error) { 77 | echo "\nException while running sample code: " . $error; 78 | } 79 | } 80 | 81 | public static function initializeSdk() { 82 | 83 | # Update the api domain based on in which data center user register your apikey 84 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 85 | $environment = new Production("https://api.office-integrator.com"); 86 | # User your apikey that you have in office integrator dashboard 87 | //Update this apikey with your own apikey signed up in office inetgrator service 88 | $authBuilder = new AuthBuilder(); 89 | $authentication = new Authentication(); 90 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 91 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 92 | $tokens = [ $authBuilder->build() ]; 93 | 94 | # Configure a proper file path to write the sdk logs 95 | $logger = (new LogBuilder()) 96 | ->level(Levels::INFO) 97 | ->filePath("./app.log") 98 | ->build(); 99 | 100 | (new InitializeBuilder()) 101 | ->environment($environment) 102 | ->tokens($tokens) 103 | ->logger($logger) 104 | ->initialize(); 105 | 106 | echo "SDK initialized successfully.\n"; 107 | } 108 | } 109 | 110 | PreviewDocument::execute(); -------------------------------------------------------------------------------- /presentation-apis/ConvertPresentation.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 34 | 35 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 36 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Zoho_Show.pptx"; 37 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 38 | 39 | $parameters->setFormat("pdf"); 40 | 41 | $responseObject = $sdkOperations->convertPresentation($parameters); 42 | 43 | if ($responseObject != null) { 44 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 45 | 46 | // Get the API response object from responseObject 47 | $presentationResponseObject = $responseObject->getObject(); 48 | 49 | if ($presentationResponseObject != null) { 50 | if ($presentationResponseObject instanceof FileBodyWrapper) { 51 | $convertedDocument = $presentationResponseObject->getFile(); 52 | 53 | if ($convertedDocument instanceof StreamWrapper) { 54 | $outputFilePath = __DIR__ . "/sample_documents/conversion_output.pdf"; 55 | 56 | file_put_contents($outputFilePath, $convertedDocument->getStream()); 57 | echo "\nCheck converted output file in file path - " . $outputFilePath . "\n"; 58 | } 59 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 60 | echo "\nInvalid configuration exception." . "\n"; 61 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 62 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 63 | if ( $presentationResponseObject->getKeyName() ) { 64 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 65 | } 66 | if ( $presentationResponseObject->getParameterName() ) { 67 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 68 | } 69 | } else { 70 | echo "\nConversion request not completed successfully\n"; 71 | } 72 | } 73 | } 74 | } catch (Exception $error) { 75 | echo "\nException while running sample code: " . $error . "\n"; 76 | } 77 | } 78 | 79 | public static function initializeSdk() { 80 | 81 | # Update the api domain based on in which data center user register your apikey 82 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 83 | $environment = new Production("https://api.office-integrator.com"); 84 | # User your apikey that you have in office integrator dashboard 85 | //Update this apikey with your own apikey signed up in office inetgrator service 86 | $authBuilder = new AuthBuilder(); 87 | $authentication = new Authentication(); 88 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 89 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 90 | $tokens = [ $authBuilder->build() ]; 91 | 92 | # Configure a proper file path to write the sdk logs 93 | $logger = (new LogBuilder()) 94 | ->level(Levels::INFO) 95 | ->filePath("./app.log") 96 | ->build(); 97 | 98 | (new InitializeBuilder()) 99 | ->environment($environment) 100 | ->tokens($tokens) 101 | ->logger($logger) 102 | ->initialize(); 103 | 104 | echo "SDK initialized successfully.\n"; 105 | } 106 | } 107 | 108 | ConvertPresentation::execute(); 109 | 110 | -------------------------------------------------------------------------------- /spreadsheet-apis/ConvertSpreadsheet.php: -------------------------------------------------------------------------------- 1 | setUrl('https://demo.office-integrator.com/samples/sheet/Contact_List.xlsx'); 35 | 36 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 37 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Contact_List.xlsx"; 38 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 39 | 40 | $outputOptions = new SheetConversionOutputOptions(); 41 | 42 | $outputOptions->setFormat('pdf'); 43 | $outputOptions->setDocumentName('ConvertedSheet.pdf'); 44 | 45 | $parameters->setOutputOptions($outputOptions); 46 | 47 | $responseObject = $sdkOperations->convertSheet($parameters); 48 | 49 | if ($responseObject != null) { 50 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 51 | 52 | // Get the API response object from responseObject 53 | $spreadsheetResponseObject = $responseObject->getObject(); 54 | 55 | if ($spreadsheetResponseObject != null) { 56 | if ($spreadsheetResponseObject instanceof FileBodyWrapper) { 57 | $convertedDocument = $spreadsheetResponseObject->getFile(); 58 | 59 | if ($convertedDocument instanceof StreamWrapper) { 60 | $outputFilePath = __DIR__ . "/sample_documents/conversion_output.pdf"; 61 | 62 | file_put_contents($outputFilePath, $convertedDocument->getStream()); 63 | echo "\nCheck converted output file in file path - " . $outputFilePath . "\n"; 64 | } 65 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 66 | echo "\nInvalid configuration exception." . "\n"; 67 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 68 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 69 | if ( $spreadsheetResponseObject->getKeyName() ) { 70 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 71 | } 72 | if ( $spreadsheetResponseObject->getParameterName() ) { 73 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 74 | } 75 | } else { 76 | echo "\nConversion request not completed successfully\n"; 77 | } 78 | } 79 | } 80 | } catch (Exception $error) { 81 | echo "\nException while running sample code: " . $error . "\n"; 82 | } 83 | } 84 | 85 | public static function initializeSdk() { 86 | 87 | # Update the api domain based on in which data center user register your apikey 88 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 89 | $environment = new Production("https://api.office-integrator.com"); 90 | # User your apikey that you have in office integrator dashboard 91 | //Update this apikey with your own apikey signed up in office inetgrator service 92 | $authBuilder = new AuthBuilder(); 93 | $authentication = new Authentication(); 94 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 95 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 96 | $tokens = [ $authBuilder->build() ]; 97 | 98 | # Configure a proper file path to write the sdk logs 99 | $logger = (new LogBuilder()) 100 | ->level(Levels::INFO) 101 | ->filePath("./app.log") 102 | ->build(); 103 | 104 | (new InitializeBuilder()) 105 | ->environment($environment) 106 | ->tokens($tokens) 107 | ->logger($logger) 108 | ->initialize(); 109 | 110 | echo "SDK initialized successfully.\n"; 111 | } 112 | } 113 | 114 | ConvertSpreadsheet::execute(); 115 | 116 | -------------------------------------------------------------------------------- /document-apis/MergeAndDownload.php: -------------------------------------------------------------------------------- 1 | setFileUrl("https://demo.office-integrator.com/zdocs/OfferLetter.zdoc"); 35 | 36 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 37 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "OfferLetter.zdoc"; 38 | // $parameters->setFileContent(new StreamWrapper(null, null, $filePath)); 39 | 40 | $parameters->setMergeDataJsonUrl('https://demo.office-integrator.com/data/candidates.json'); 41 | 42 | // $jsonFilePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "candidates.json"; 43 | // $parameters->setMergeDataJsonContent(new StreamWrapper(null, null, $jsonFilePath)); 44 | 45 | $parameters->setPassword("***"); 46 | $parameters->setOutputFormat("pdf"); 47 | 48 | $responseObject = $sdkOperations->mergeAndDownloadDocument($parameters); 49 | 50 | if ($responseObject !== null) { 51 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 52 | 53 | $writerResponseObject = $responseObject->getObject(); 54 | 55 | if ($writerResponseObject !== null) { 56 | if ($writerResponseObject instanceof FileBodyWrapper) { 57 | $convertedDocument = $writerResponseObject->getFile(); 58 | 59 | if ($convertedDocument instanceof StreamWrapper) { 60 | $outputFilePath = __DIR__ . "/sample_documents/merge_and_download.pdf"; 61 | 62 | file_put_contents($outputFilePath, $convertedDocument->getStream()); 63 | echo "\nCheck merged output file in file path - $outputFilePath\n"; 64 | } 65 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 66 | echo "\nInvalid configuration exception." . "\n"; 67 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 68 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 69 | if ( $writerResponseObject->getKeyName() ) { 70 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 71 | } 72 | if ( $writerResponseObject->getParameterName() ) { 73 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 74 | } 75 | } else { 76 | echo "\nRequest not completed successfully\n"; 77 | } 78 | } 79 | } 80 | } catch (\Exception $error) { 81 | echo "\nException while running sample code: " . $error->getMessage() . "\n"; 82 | } 83 | } 84 | 85 | public static function initializeSdk() { 86 | 87 | # Update the api domain based on in which data center user register your apikey 88 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 89 | $environment = new Production("https://api.office-integrator.com"); 90 | # User your apikey that you have in office integrator dashboard 91 | //Update this apikey with your own apikey signed up in office inetgrator service 92 | $authBuilder = new AuthBuilder(); 93 | $authentication = new Authentication(); 94 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 95 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 96 | $tokens = [ $authBuilder->build() ]; 97 | 98 | # Configure a proper file path to write the sdk logs 99 | $logger = (new LogBuilder()) 100 | ->level(Levels::INFO) 101 | ->filePath("./app.log") 102 | ->build(); 103 | 104 | (new InitializeBuilder()) 105 | ->environment($environment) 106 | ->tokens($tokens) 107 | ->logger($logger) 108 | ->initialize(); 109 | 110 | echo "SDK initialized successfully.\n"; 111 | } 112 | } 113 | 114 | MergeAndDownload::execute(); 115 | -------------------------------------------------------------------------------- /document-apis/GetMergeFields.php: -------------------------------------------------------------------------------- 1 | setFileUrl('https://demo.office-integrator.com/zdocs/OfferLetter.zdoc'); 34 | 35 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 36 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "OfferLetter.zdoc"; 37 | // $getMergeFieldsParams->setFileContent(new StreamWrapper(null, null, $filePath)); 38 | 39 | $responseObject = $sdkOperations->getMergeFields($getMergeFieldsParams); 40 | 41 | if ($responseObject != null) { 42 | // Get the status code from response 43 | echo "\n Status Code: " . $responseObject->getStatusCode() . "\n"; 44 | 45 | // Get the api response object from responseObject 46 | $writerResponseObject = $responseObject->getObject(); 47 | 48 | if ($writerResponseObject != null) { 49 | // Check if the expected CreateDocumentResponse instance is received 50 | if ($writerResponseObject instanceof MergeFieldsResponse) { 51 | $mergeFieldsObj = $writerResponseObject->getMerge(); 52 | 53 | echo "\n Total Fields in Document - " . sizeof($mergeFieldsObj) . "\n"; 54 | 55 | foreach ( $mergeFieldsObj as $mergeFieldObj ) { 56 | if ( $mergeFieldObj instanceof MergeFields ) { 57 | echo "\n\n Merge Field ID - " . $mergeFieldObj->getId(); 58 | echo "\n Merge Field Display Name - " . $mergeFieldObj->getDisplayName(); 59 | echo "\n Merge Field Type - " . $mergeFieldObj->getType(); } 60 | } 61 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 62 | echo "\nInvalid configuration exception." . "\n"; 63 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 64 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 65 | if ( $writerResponseObject->getKeyName() ) { 66 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 67 | } 68 | if ( $writerResponseObject->getParameterName() ) { 69 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 70 | } 71 | } else { 72 | echo "\nRequest not completed successfully\n"; 73 | } 74 | } 75 | } 76 | } catch (Exception $error) { 77 | echo "\nException while running sample code: " . $error . "\n"; 78 | } 79 | } 80 | 81 | public static function initializeSdk() { 82 | 83 | # Update the api domain based on in which data center user register your apikey 84 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 85 | $environment = new Production("https://api.office-integrator.com"); 86 | # User your apikey that you have in office integrator dashboard 87 | //Update this apikey with your own apikey signed up in office inetgrator service 88 | $authBuilder = new AuthBuilder(); 89 | $authentication = new Authentication(); 90 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 91 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 92 | $tokens = [ $authBuilder->build() ]; 93 | 94 | # Configure a proper file path to write the sdk logs 95 | $logger = (new LogBuilder()) 96 | ->level(Levels::INFO) 97 | ->filePath("./app.log") 98 | ->build(); 99 | 100 | (new InitializeBuilder()) 101 | ->environment($environment) 102 | ->tokens($tokens) 103 | ->logger($logger) 104 | ->initialize(); 105 | 106 | echo "SDK initialized successfully.\n"; 107 | } 108 | } 109 | 110 | GetMergeFields::execute(); 111 | 112 | -------------------------------------------------------------------------------- /document-apis/WatermarkDocument.php: -------------------------------------------------------------------------------- 1 | setUrl("https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx"); 33 | 34 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 35 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Graphic-Design-Proposal.docx"; 36 | // $watermarkParameter->setDocument(new StreamWrapper(null, null, $filePath)); 37 | 38 | $watermarkSettings = new WatermarkSettings(); 39 | 40 | $watermarkSettings->setType("text"); 41 | $watermarkSettings->getFontSize(18); 42 | $watermarkSettings->setOpacity(70.00); 43 | $watermarkSettings->setFontName("Arial"); 44 | $watermarkSettings->setFontColor("#cd4544"); 45 | $watermarkSettings->setOrientation("horizontal"); 46 | $watermarkSettings->setText("Sample Water Mark Text"); 47 | 48 | $watermarkParameter->setWatermarkSettings($watermarkSettings); 49 | 50 | $responseObject = $sdkOperations->createWatermarkDocument($watermarkParameter); 51 | 52 | if ($responseObject !== null) { 53 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 54 | 55 | $writerResponseObject = $responseObject->getObject(); 56 | 57 | if ($writerResponseObject !== null) { 58 | if ($writerResponseObject instanceof FileBodyWrapper) { 59 | $convertedDocument = $writerResponseObject->getFile(); 60 | 61 | if ($convertedDocument instanceof StreamWrapper) { 62 | $outputFilePath = __DIR__ . "/sample_documents/WaterMark_Output.docx"; 63 | 64 | file_put_contents($outputFilePath, $convertedDocument->getStream()); 65 | echo "\nWater mark output file in file path - $outputFilePath\n"; 66 | } 67 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 68 | echo "\nInvalid configuration exception." . "\n"; 69 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 70 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 71 | if ( $writerResponseObject->getKeyName() ) { 72 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 73 | } 74 | if ( $writerResponseObject->getParameterName() ) { 75 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 76 | } 77 | } else { 78 | echo "\nRequest not completed successfully\n"; 79 | } 80 | } 81 | } 82 | } catch (\Exception $error) { 83 | echo "\nException while running sample code: " . $error; 84 | } 85 | } 86 | 87 | public static function initializeSdk() { 88 | 89 | # Update the api domain based on in which data center user register your apikey 90 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 91 | $environment = new Production("https://api.office-integrator.com"); 92 | # User your apikey that you have in office integrator dashboard 93 | //Update this apikey with your own apikey signed up in office inetgrator service 94 | $authBuilder = new AuthBuilder(); 95 | $authentication = new Authentication(); 96 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 97 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 98 | $tokens = [ $authBuilder->build() ]; 99 | 100 | # Configure a proper file path to write the sdk logs 101 | $logger = (new LogBuilder()) 102 | ->level(Levels::INFO) 103 | ->filePath("./app.log") 104 | ->build(); 105 | 106 | (new InitializeBuilder()) 107 | ->environment($environment) 108 | ->tokens($tokens) 109 | ->logger($logger) 110 | ->initialize(); 111 | 112 | echo "SDK initialized successfully.\n"; 113 | } 114 | } 115 | 116 | WatermarkDocument::execute(); -------------------------------------------------------------------------------- /document-apis/CompareDocument.php: -------------------------------------------------------------------------------- 1 | setUrl1("https://demo.office-integrator.com/zdocs/MS_Word_Document_v0.docx"); 32 | $compareDocumentParameters->setUrl2("https://demo.office-integrator.com/zdocs/MS_Word_Document_v1.docx"); 33 | 34 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 35 | $file1Name = "MS_Word_Document_v0.docx"; 36 | // $file1Path = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "MS_Word_Document_v0.docx"; 37 | // $compareDocumentParameters->setDocument1(new StreamWrapper(null, null, $file1Path)); 38 | 39 | $file2Name = "MS_Word_Document_v1.docx"; 40 | // $file2Path = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "MS_Word_Document_v1.docx"; 41 | // $compareDocumentParameters->setDocument2(new StreamWrapper(null, null, $file2Path)); 42 | 43 | # Optional Configurations - To set language of the compare document user interface 44 | $compareDocumentParameters->setLang("en"); 45 | $compareDocumentParameters->setTitle($file1Name . " vs " . $file2Name); 46 | 47 | $responseObject = $sdkOperations->compareDocument($compareDocumentParameters); 48 | 49 | if ($responseObject != null) { 50 | // Get the status code from response 51 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 52 | 53 | // Get the API response object from responseObject 54 | $writerResponseObject = $responseObject->getObject(); 55 | 56 | if ($writerResponseObject != null) { 57 | // Check if the expected CompareDocumentResponse instance is received 58 | if ($writerResponseObject instanceof CompareDocumentResponse) { 59 | echo "\nCompare URL - " . $writerResponseObject->getCompareUrl() . "\n"; 60 | echo "\nDocument session delete URL - " . $writerResponseObject->getSessionDeleteUrl() . "\n"; 61 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 62 | echo "\nInvalid configuration exception." . "\n"; 63 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 64 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 65 | if ( $writerResponseObject->getKeyName() ) { 66 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 67 | } 68 | if ( $writerResponseObject->getParameterName() ) { 69 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 70 | } 71 | } else { 72 | echo "\nRequest not completed successfully\n"; 73 | } 74 | } 75 | } 76 | } catch (Exception $error) { 77 | echo "\nException while running sample code: " . $error->getMessage() . "\n"; 78 | } 79 | } 80 | 81 | public static function initializeSdk() { 82 | 83 | # Update the api domain based on in which data center user register your apikey 84 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 85 | $environment = new Production("https://api.office-integrator.com"); 86 | # User your apikey that you have in office integrator dashboard 87 | //Update this apikey with your own apikey signed up in office inetgrator service 88 | $authBuilder = new AuthBuilder(); 89 | $authentication = new Authentication(); 90 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 91 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 92 | $tokens = [ $authBuilder->build() ]; 93 | 94 | # Configure a proper file path to write the sdk logs 95 | $logger = (new LogBuilder()) 96 | ->level(Levels::INFO) 97 | ->filePath("./app.log") 98 | ->build(); 99 | 100 | (new InitializeBuilder()) 101 | ->environment($environment) 102 | ->tokens($tokens) 103 | ->logger($logger) 104 | ->initialize(); 105 | 106 | echo "SDK initialized successfully.\n"; 107 | } 108 | } 109 | 110 | CompareDocument::execute(); 111 | 112 | ?> 113 | -------------------------------------------------------------------------------- /spreadsheet-apis/PreviewSpreadsheet.php: -------------------------------------------------------------------------------- 1 | setUrl('https://demo.office-integrator.com/samples/sheet/Contact_List.xlsx'); 33 | 34 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 35 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Contact_List.xlsx"; 36 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 37 | 38 | $parameters->setLanguage("en"); 39 | 40 | $permissions = array(); 41 | 42 | $permissions["document.export"] = "true"; 43 | $permissions["document.print"] = "true"; 44 | 45 | $parameters->setPermissions($permissions); 46 | 47 | $responseObject = $sdkOperations->createSheetPreview($parameters); 48 | 49 | if ($responseObject != null) { 50 | // Get the status code from response 51 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 52 | 53 | // Get the api response object from responseObject 54 | $spreadsheetResponseObject = $responseObject->getObject(); 55 | 56 | if ($spreadsheetResponseObject != null) { 57 | // Check if the expected CreateDocumentResponse instance is received 58 | if ($spreadsheetResponseObject instanceof SheetPreviewResponse) { 59 | echo "\nSpreadsheet ID - " . $spreadsheetResponseObject->getDocumentId() . "\n"; 60 | echo "\nSpreadsheet session ID - " . $spreadsheetResponseObject->getSessionId() . "\n"; 61 | echo "\nSpreadsheet preview session URL - " . $spreadsheetResponseObject->getPreviewUrl() . "\n"; 62 | echo "\nSpreadsheet delete URL - " . $spreadsheetResponseObject->getDocumentDeleteUrl() . "\n"; 63 | echo "\nSpreadsheet session delete URL - " . $spreadsheetResponseObject->getSessionDeleteUrl() . "\n"; 64 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 65 | echo "\nInvalid configuration exception." . "\n"; 66 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 67 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 68 | if ( $spreadsheetResponseObject->getKeyName() ) { 69 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 70 | } 71 | if ( $spreadsheetResponseObject->getParameterName() ) { 72 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 73 | } 74 | } else { 75 | echo "\nRequest not completed successfully\n"; 76 | } 77 | } 78 | } 79 | } catch (Exception $error) { 80 | echo "\nException while running sample code: " . $error . "\n"; 81 | } 82 | } 83 | 84 | public static function initializeSdk() { 85 | 86 | # Update the api domain based on in which data center user register your apikey 87 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 88 | $environment = new Production("https://api.office-integrator.com"); 89 | # User your apikey that you have in office integrator dashboard 90 | //Update this apikey with your own apikey signed up in office inetgrator service 91 | $authBuilder = new AuthBuilder(); 92 | $authentication = new Authentication(); 93 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 94 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 95 | $tokens = [ $authBuilder->build() ]; 96 | 97 | # Configure a proper file path to write the sdk logs 98 | $logger = (new LogBuilder()) 99 | ->level(Levels::INFO) 100 | ->filePath("./app.log") 101 | ->build(); 102 | 103 | (new InitializeBuilder()) 104 | ->environment($environment) 105 | ->tokens($tokens) 106 | ->logger($logger) 107 | ->initialize(); 108 | 109 | echo "SDK initialized successfully.\n"; 110 | } 111 | } 112 | 113 | PreviewSpreadsheet::execute(); 114 | 115 | -------------------------------------------------------------------------------- /presentation-apis/PreviewPresentation.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 35 | 36 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 37 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Zoho_Show.pptx"; 38 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 39 | 40 | $documentInfo = new DocumentInfo(); 41 | 42 | // Time value used to generate a unique document every time. You can replace it based on your application. 43 | $documentInfo->setDocumentId(strval(time())); 44 | $documentInfo->setDocumentName("New Presentation"); 45 | 46 | $parameters->setDocumentInfo($documentInfo); 47 | 48 | $parameters->setLanguage("en"); 49 | 50 | $responseObject = $sdkOperations->createPresentationPreview($parameters); 51 | 52 | if ($responseObject != null) { 53 | // Get the status code from response 54 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 55 | 56 | // Get the api response object from responseObject 57 | $presentationResponseObject = $responseObject->getObject(); 58 | 59 | if ($presentationResponseObject != null) { 60 | // Check if the expected CreateDocumentResponse instance is received 61 | if ($presentationResponseObject instanceof PreviewResponse) { 62 | echo "\nPresentation ID - " . $presentationResponseObject->getDocumentId() . "\n"; 63 | echo "\nPresentation session ID - " . $presentationResponseObject->getSessionId() . "\n"; 64 | echo "\nPresentation Preview session URL - " . $presentationResponseObject->getPreviewUrl() . "\n"; 65 | echo "\nPresentation delete URL - " . $presentationResponseObject->getDocumentDeleteUrl() . "\n"; 66 | echo "\nPresentation session delete URL - " . $presentationResponseObject->getSessionDeleteUrl() . "\n"; 67 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 68 | echo "\nInvalid configuration exception." . "\n"; 69 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 70 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 71 | if ( $presentationResponseObject->getKeyName() ) { 72 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 73 | } 74 | if ( $presentationResponseObject->getParameterName() ) { 75 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 76 | } 77 | } else { 78 | echo "\nRequest not completed successfully\n"; 79 | } 80 | } 81 | } 82 | } catch (Exception $error) { 83 | echo "\nException while running sample code: " . $error . "\n"; 84 | } 85 | } 86 | 87 | public static function initializeSdk() { 88 | 89 | # Update the api domain based on in which data center user register your apikey 90 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 91 | $environment = new Production("https://api.office-integrator.com"); 92 | # User your apikey that you have in office integrator dashboard 93 | //Update this apikey with your own apikey signed up in office inetgrator service 94 | $authBuilder = new AuthBuilder(); 95 | $authentication = new Authentication(); 96 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 97 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 98 | $tokens = [ $authBuilder->build() ]; 99 | 100 | # Configure a proper file path to write the sdk logs 101 | $logger = (new LogBuilder()) 102 | ->level(Levels::INFO) 103 | ->filePath("./app.log") 104 | ->build(); 105 | 106 | (new InitializeBuilder()) 107 | ->environment($environment) 108 | ->tokens($tokens) 109 | ->logger($logger) 110 | ->initialize(); 111 | 112 | echo "SDK initialized successfully.\n"; 113 | } 114 | } 115 | 116 | PreviewPresentation::execute(); 117 | 118 | -------------------------------------------------------------------------------- /document-apis/ConvertDocument.php: -------------------------------------------------------------------------------- 1 | setUrl("https://demo.office-integrator.com/zdocs/MS_Word_Document_v0.docx"); 35 | 36 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 37 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Graphic-Design-Proposal.docx"; 38 | // $documentConversionParameters->setDocument(new StreamWrapper(null, null, $filePath)); 39 | 40 | $outputOptions = new DocumentConversionOutputOptions(); 41 | 42 | $outputOptions->setFormat("pdf"); 43 | $outputOptions->setDocumentName("conversion_output.pdf"); 44 | $outputOptions->setIncludeComments("all"); 45 | $outputOptions->setIncludeChanges("all"); 46 | $outputOptions->setPassword("***"); 47 | 48 | $documentConversionParameters->setOutputOptions($outputOptions); 49 | 50 | // if input document is password protected, then please configure that password in below code 51 | // $documentConversionParameters->setPassword("***"); 52 | 53 | $responseObject = $sdkOperations->convertDocument($documentConversionParameters); 54 | 55 | if ($responseObject != null) { 56 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 57 | 58 | // Get the API response object from responseObject 59 | $writerResponseObject = $responseObject->getObject(); 60 | 61 | if ($writerResponseObject != null) { 62 | if ($writerResponseObject instanceof FileBodyWrapper) { 63 | $convertedDocument = $writerResponseObject->getFile(); 64 | 65 | if ($convertedDocument instanceof StreamWrapper) { 66 | $outputFilePath = __DIR__ . "/sample_documents/conversion_output.pdf"; 67 | 68 | file_put_contents($outputFilePath, $convertedDocument->getStream()); 69 | echo "\nCheck converted output file in file path - " . $outputFilePath . "\n"; 70 | } 71 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 72 | echo "\nInvalid configuration exception." . "\n"; 73 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 74 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 75 | if ( $writerResponseObject->getKeyName() ) { 76 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 77 | } 78 | if ( $writerResponseObject->getParameterName() ) { 79 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 80 | } 81 | } else { 82 | echo "\nConversion request not completed successfully\n"; 83 | } 84 | } 85 | } 86 | } catch (Exception $error) { 87 | echo "\nException while running sample code: " . $error->getMessage() . "\n"; 88 | } 89 | } 90 | 91 | public static function initializeSdk() { 92 | 93 | # Update the api domain based on in which data center user register your apikey 94 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 95 | $environment = new Production("https://api.office-integrator.com"); 96 | # User your apikey that you have in office integrator dashboard 97 | //Update this apikey with your own apikey signed up in office inetgrator service 98 | $authBuilder = new AuthBuilder(); 99 | $authentication = new Authentication(); 100 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 101 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 102 | $tokens = [ $authBuilder->build() ]; 103 | 104 | # Configure a proper file path to write the sdk logs 105 | $logger = (new LogBuilder()) 106 | ->level(Levels::INFO) 107 | ->filePath("./app.log") 108 | ->build(); 109 | 110 | (new InitializeBuilder()) 111 | ->environment($environment) 112 | ->tokens($tokens) 113 | ->logger($logger) 114 | ->initialize(); 115 | 116 | echo "SDK initialized successfully.\n"; 117 | } 118 | } 119 | 120 | ConvertDocument::execute(); 121 | 122 | ?> 123 | -------------------------------------------------------------------------------- /document-apis/MergeAndDeliver.php: -------------------------------------------------------------------------------- 1 | setFileUrl("https://demo.office-integrator.com/zdocs/OfferLetter.zdoc"); 36 | 37 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 38 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "OfferLetter.zdoc"; 39 | // $parameters->setFileContent(new StreamWrapper(null, null, $filePath)); 40 | 41 | $parameters->setMergeDataJsonUrl('https://demo.office-integrator.com/data/candidates.json'); 42 | 43 | // $jsonFilePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "candidates.json"; 44 | // $parameters->setMergeDataJsonContent(new StreamWrapper(null, null, $jsonFilePath)); 45 | 46 | $parameters->setPassword("***"); 47 | $parameters->setOutputFormat("pdf"); 48 | $parameters->setMergeTo('separatedoc'); 49 | 50 | $webhookSettings = new MailMergeWebhookSettings(); 51 | 52 | $webhookSettings->setInvokeUrl('https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157a25e63fc4dfd4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286'); 53 | $webhookSettings->setInvokePeriod('oncomplete'); 54 | 55 | $parameters->setWebhook($webhookSettings); 56 | 57 | $responseObject = $sdkOperations->mergeAndDeliverViaWebhook($parameters); 58 | 59 | if ($responseObject !== null) { 60 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 61 | 62 | $writerResponseObject = $responseObject->getObject(); 63 | 64 | if ($writerResponseObject !== null) { 65 | if ($writerResponseObject instanceof MergeAndDeliverViaWebhookSuccessResponse) { 66 | $mergeReportUrl = $writerResponseObject->getMergeReportDataUrl(); 67 | 68 | echo "\nMerge Report URL - " . $mergeReportUrl . "\n"; 69 | 70 | $records = $writerResponseObject->getRecords(); 71 | 72 | foreach ( $records as $record ) { 73 | if ($record instanceof MergeAndDeliverRecordsMeta) { 74 | echo "\n\nRecord Name : " . $record->getName(); 75 | echo "\nRecord Email : " . $record->getEmail(); 76 | echo "\nRecord Status : " . $record->getStatus(); 77 | echo "\nRecord Download Link : " . $record->getDownloadLink(); 78 | } 79 | } 80 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 81 | echo "\nInvalid configuration exception." . "\n"; 82 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 83 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 84 | if ( $writerResponseObject->getKeyName() ) { 85 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 86 | } 87 | if ( $writerResponseObject->getParameterName() ) { 88 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 89 | } 90 | } else { 91 | echo "\nRequest not completed successfully\n"; 92 | } 93 | } 94 | } 95 | } catch (\Exception $error) { 96 | echo "\nException while running sample code: " . $error->getMessage() . "\n"; 97 | } 98 | } 99 | 100 | public static function initializeSdk() { 101 | 102 | # Update the api domain based on in which data center user register your apikey 103 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 104 | $environment = new Production("https://api.office-integrator.com"); 105 | # User your apikey that you have in office integrator dashboard 106 | //Update this apikey with your own apikey signed up in office inetgrator service 107 | $authBuilder = new AuthBuilder(); 108 | $authentication = new Authentication(); 109 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 110 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 111 | $tokens = [ $authBuilder->build() ]; 112 | 113 | # Configure a proper file path to write the sdk logs 114 | $logger = (new LogBuilder()) 115 | ->level(Levels::INFO) 116 | ->filePath("./app.log") 117 | ->build(); 118 | 119 | (new InitializeBuilder()) 120 | ->environment($environment) 121 | ->tokens($tokens) 122 | ->logger($logger) 123 | ->initialize(); 124 | 125 | echo "SDK initialized successfully.\n"; 126 | } 127 | } 128 | 129 | MergeAndDeliver::execute(); 130 | -------------------------------------------------------------------------------- /pdf-apis/DeletePdf.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 34 | 35 | $responseObject = $sdkOperations->editPdf($parameters); 36 | 37 | if ($responseObject != null) { 38 | // Get the status code from response 39 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 40 | 41 | // Get the api response object from responseObject 42 | $presentationResponseObject = $responseObject->getObject(); 43 | 44 | if ($presentationResponseObject != null) { 45 | // Check if the expected CreateDocumentResponse instance is received 46 | if ($presentationResponseObject instanceof CreateDocumentResponse) { 47 | $documentId = $presentationResponseObject->getDocumentId(); 48 | 49 | echo "\nPdf ID to be deleted - " . $documentId . "\n"; 50 | 51 | $deleteApiResponse = $sdkOperations->deletePdfDocument($documentId); 52 | 53 | if ($deleteApiResponse != null) { 54 | // Get the status code from response 55 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 56 | 57 | // Get the api response object from responseObject 58 | $deleteResponseObject = $deleteApiResponse->getObject(); 59 | 60 | if ($deleteResponseObject != null) { 61 | // Check if the expected CreateDocumentResponse instance is received 62 | if ($deleteResponseObject instanceof DocumentDeleteSuccessResponse) { 63 | echo "\nPdf delete status : - " . $deleteResponseObject->getDocumentDeleted() . "\n"; 64 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 65 | echo "\nInvalid configuration exception." . "\n"; 66 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 67 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 68 | if ( $deleteResponseObject->getKeyName() ) { 69 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 70 | } 71 | if ( $deleteResponseObject->getParameterName() ) { 72 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 73 | } 74 | } else { 75 | echo "\nRequest not completed successfully\n"; 76 | } 77 | } 78 | } 79 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 80 | echo "\nInvalid configuration exception." . "\n"; 81 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 82 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 83 | if ( $presentationResponseObject->getKeyName() ) { 84 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 85 | } 86 | if ( $presentationResponseObject->getParameterName() ) { 87 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 88 | } 89 | } else { 90 | echo "\nRequest not completed successfully\n"; 91 | } 92 | } 93 | } 94 | } catch (Exception $error) { 95 | echo "\nException while running sample code: " . $error . "\n"; 96 | } 97 | } 98 | 99 | public static function initializeSdk() { 100 | 101 | # Update the api domain based on in which data center user register your apikey 102 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 103 | $environment = new Production("https://api.office-integrator.com"); 104 | # User your apikey that you have in office integrator dashboard 105 | //Update this apikey with your own apikey signed up in office inetgrator service 106 | $authBuilder = new AuthBuilder(); 107 | $authentication = new Authentication(); 108 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 109 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 110 | $tokens = [ $authBuilder->build() ]; 111 | 112 | # Configure a proper file path to write the sdk logs 113 | $logger = (new LogBuilder()) 114 | ->level(Levels::INFO) 115 | ->filePath("./app.log") 116 | ->build(); 117 | 118 | (new InitializeBuilder()) 119 | ->environment($environment) 120 | ->tokens($tokens) 121 | ->logger($logger) 122 | ->initialize(); 123 | 124 | echo "SDK initialized successfully.\n"; 125 | } 126 | } 127 | 128 | DeletePdf::execute(); 129 | -------------------------------------------------------------------------------- /pdf-apis/DeletePdfSession.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 34 | 35 | $responseObject = $sdkOperations->editPdf($parameters); 36 | 37 | if ($responseObject != null) { 38 | // Get the status code from response 39 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 40 | 41 | // Get the api response object from responseObject 42 | $presentationResponseObject = $responseObject->getObject(); 43 | 44 | if ($presentationResponseObject != null) { 45 | // Check if the expected CreateDocumentResponse instance is received 46 | if ($presentationResponseObject instanceof CreateDocumentResponse) { 47 | $sessionId = $presentationResponseObject->getSessionId(); 48 | 49 | echo "\nPdf Session ID to be deleted - " . $sessionId . "\n"; 50 | 51 | $deleteApiResponse = $sdkOperations->deletePdfDocumentSession($sessionId); 52 | 53 | if ($deleteApiResponse != null) { 54 | // Get the status code from response 55 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 56 | 57 | // Get the api response object from responseObject 58 | $deleteResponseObject = $deleteApiResponse->getObject(); 59 | 60 | if ($deleteResponseObject != null) { 61 | // Check if the expected CreateDocumentResponse instance is received 62 | if ($deleteResponseObject instanceof DocumentSessionDeleteSuccessResponse) { 63 | echo "\nPdf session delete status : - " . $deleteResponseObject->getSessionDeleted() . "\n"; 64 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 65 | echo "\nInvalid configuration exception." . "\n"; 66 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 67 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 68 | if ( $deleteResponseObject->getKeyName() ) { 69 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 70 | } 71 | if ( $deleteResponseObject->getParameterName() ) { 72 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 73 | } 74 | } else { 75 | echo "\nRequest not completed successfully\n"; 76 | } 77 | } 78 | } 79 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 80 | echo "\nInvalid configuration exception." . "\n"; 81 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 82 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 83 | if ( $presentationResponseObject->getKeyName() ) { 84 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 85 | } 86 | if ( $presentationResponseObject->getParameterName() ) { 87 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 88 | } 89 | } else { 90 | echo "\nRequest not completed successfully\n"; 91 | } 92 | } 93 | } 94 | } catch (Exception $error) { 95 | echo "\nException while running sample code: " . $error . "\n"; 96 | } 97 | } 98 | 99 | public static function initializeSdk() { 100 | 101 | # Update the api domain based on in which data center user register your apikey 102 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 103 | $environment = new Production("https://api.office-integrator.com"); 104 | # User your apikey that you have in office integrator dashboard 105 | //Update this apikey with your own apikey signed up in office inetgrator service 106 | $authBuilder = new AuthBuilder(); 107 | $authentication = new Authentication(); 108 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 109 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 110 | $tokens = [ $authBuilder->build() ]; 111 | 112 | # Configure a proper file path to write the sdk logs 113 | $logger = (new LogBuilder()) 114 | ->level(Levels::INFO) 115 | ->filePath("./app.log") 116 | ->build(); 117 | 118 | (new InitializeBuilder()) 119 | ->environment($environment) 120 | ->tokens($tokens) 121 | ->logger($logger) 122 | ->initialize(); 123 | 124 | echo "SDK initialized successfully.\n"; 125 | } 126 | } 127 | 128 | DeletePdfSession::execute(); 129 | -------------------------------------------------------------------------------- /pdf-apis/GetPdfSessionDetails.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 34 | 35 | $responseObject = $sdkOperations->editPdf($parameters); 36 | 37 | if ($responseObject != null) { 38 | // Get the status code from response 39 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 40 | 41 | // Get the api response object from responseObject 42 | $writerResponseObject = $responseObject->getObject(); 43 | 44 | if ($writerResponseObject != null) { 45 | // Check if the expected CreateDocumentResponse instance is received 46 | if ($writerResponseObject instanceof CreateDocumentResponse) { 47 | $sessionId = $writerResponseObject->getSessionId(); 48 | 49 | echo "\nCreated PDF Session ID : " . $sessionId . "\n"; 50 | 51 | $documentDetailsResponse = $sdkOperations->getPdfDocumentSession($sessionId); 52 | 53 | if ($documentDetailsResponse != null) { 54 | // Get the status code from response 55 | echo "\nStatus Code: " . $documentDetailsResponse->getStatusCode() . "\n"; 56 | 57 | // Get the api response object from responseObject 58 | $documentSessionInfoObj = $documentDetailsResponse->getObject(); 59 | 60 | if ($documentSessionInfoObj != null) { 61 | // Check if the expected CreateDocumentResponse instance is received 62 | if ($documentSessionInfoObj instanceof SessionMeta) { 63 | echo "\nPdf Session Status : - " . $documentSessionInfoObj->getStatus() . "\n"; 64 | echo "\nPdf Session User DisplayName : - " . $documentSessionInfoObj->getUserInfo()->getDisplayName() . "\n"; 65 | echo "\nPdf Session Expires On : - " . $documentSessionInfoObj->getInfo()->getExpiresOn() . "\n"; 66 | } elseif ($documentSessionInfoObj instanceof InvalidConfigurationException) { 67 | echo "\nInvalid configuration exception." . "\n"; 68 | echo "\nError Code - " . $documentSessionInfoObj->getCode() . "\n"; 69 | echo "\nError Message - " . $documentSessionInfoObj->getMessage() . "\n"; 70 | if ( $documentSessionInfoObj->getKeyName() ) { 71 | echo "\nError Key Name - " . $documentSessionInfoObj->getKeyName() . "\n"; 72 | } 73 | if ( $documentSessionInfoObj->getParameterName() ) { 74 | echo "\nError Parameter Name - " . $documentSessionInfoObj->getParameterName() . "\n"; 75 | } 76 | } else { 77 | echo "\nRequest not completed successfully\n"; 78 | } 79 | } 80 | } 81 | 82 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 83 | echo "\nInvalid configuration exception." . "\n"; 84 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 85 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 86 | if ( $writerResponseObject->getKeyName() ) { 87 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 88 | } 89 | if ( $writerResponseObject->getParameterName() ) { 90 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 91 | } 92 | } else { 93 | echo "\nRequest not completed successfully\n"; 94 | } 95 | } 96 | } 97 | } catch (Exception $error) { 98 | echo "\nException while running sample code: " . $error . "\n"; 99 | } 100 | } 101 | 102 | public static function initializeSdk() { 103 | 104 | # Update the api domain based on in which data center user register your apikey 105 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 106 | $environment = new Production("https://api.office-integrator.com"); 107 | # User your apikey that you have in office integrator dashboard 108 | //Update this apikey with your own apikey signed up in office inetgrator service 109 | $authBuilder = new AuthBuilder(); 110 | $authentication = new Authentication(); 111 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 112 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 113 | $tokens = [ $authBuilder->build() ]; 114 | 115 | # Configure a proper file path to write the sdk logs 116 | $logger = (new LogBuilder()) 117 | ->level(Levels::INFO) 118 | ->filePath("./app.log") 119 | ->build(); 120 | 121 | (new InitializeBuilder()) 122 | ->environment($environment) 123 | ->tokens($tokens) 124 | ->logger($logger) 125 | ->initialize(); 126 | 127 | echo "SDK initialized successfully.\n"; 128 | } 129 | } 130 | 131 | GetPdfSessionDetails::execute(); 132 | -------------------------------------------------------------------------------- /spreadsheet-apis/DeleteSpreadsheet.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 37 | $documentInfo->setDocumentName("New Spreadsheet"); 38 | 39 | $parameters->setDocumentInfo($documentInfo); 40 | 41 | $responseObject = $sdkOperations->createSheet($parameters); 42 | 43 | if ($responseObject != null) { 44 | // Get the status code from response 45 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 46 | 47 | // Get the api response object from responseObject 48 | $spreadsheetResponseObject = $responseObject->getObject(); 49 | 50 | if ($spreadsheetResponseObject != null) { 51 | // Check if the expected CreateDocumentResponse instance is received 52 | if ($spreadsheetResponseObject instanceof CreateSheetResponse) { 53 | $spreadsheetId = $spreadsheetResponseObject->getDocumentId(); 54 | 55 | echo "\nSpreadsheet ID to be deleted - " . $spreadsheetId . "\n"; 56 | 57 | $deleteApiResponse = $sdkOperations->deleteSheet($spreadsheetId); 58 | 59 | if ($deleteApiResponse != null) { 60 | // Get the status code from response 61 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 62 | 63 | // Get the api response object from responseObject 64 | $deleteResponseObject = $deleteApiResponse->getObject(); 65 | 66 | if ($deleteResponseObject != null) { 67 | // Check if the expected CreateDocumentResponse instance is received 68 | if ($deleteResponseObject instanceof FileDeleteSuccessResponse) { 69 | echo "\nSpreadsheet delete status : - " . $deleteResponseObject->getDocDelete() . "\n"; 70 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 71 | echo "\nInvalid configuration exception." . "\n"; 72 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 73 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 74 | if ( $deleteResponseObject->getKeyName() ) { 75 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 76 | } 77 | if ( $deleteResponseObject->getParameterName() ) { 78 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 79 | } 80 | } else { 81 | echo "\nRequest not completed successfully\n"; 82 | } 83 | } 84 | } 85 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 86 | echo "\nInvalid configuration exception." . "\n"; 87 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 88 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 89 | if ( $spreadsheetResponseObject->getKeyName() ) { 90 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 91 | } 92 | if ( $spreadsheetResponseObject->getParameterName() ) { 93 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 94 | } 95 | } else { 96 | echo "\nRequest not completed successfully\n"; 97 | } 98 | } 99 | } 100 | } catch (Exception $error) { 101 | echo "\nException while running sample code: " . $error . "\n"; 102 | } 103 | } 104 | 105 | public static function initializeSdk() { 106 | 107 | # Update the api domain based on in which data center user register your apikey 108 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 109 | $environment = new Production("https://api.office-integrator.com"); 110 | # User your apikey that you have in office integrator dashboard 111 | //Update this apikey with your own apikey signed up in office inetgrator service 112 | $authBuilder = new AuthBuilder(); 113 | $authentication = new Authentication(); 114 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 115 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 116 | $tokens = [ $authBuilder->build() ]; 117 | 118 | # Configure a proper file path to write the sdk logs 119 | $logger = (new LogBuilder()) 120 | ->level(Levels::INFO) 121 | ->filePath("./app.log") 122 | ->build(); 123 | 124 | (new InitializeBuilder()) 125 | ->environment($environment) 126 | ->tokens($tokens) 127 | ->logger($logger) 128 | ->initialize(); 129 | 130 | echo "SDK initialized successfully.\n"; 131 | } 132 | } 133 | 134 | DeleteSpreadsheet::execute(); 135 | 136 | -------------------------------------------------------------------------------- /presentation-apis/DeletePresentation.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 37 | $documentInfo->setDocumentName("New Presentation"); 38 | 39 | $parameters->setDocumentInfo($documentInfo); 40 | 41 | $responseObject = $sdkOperations->createPresentation($parameters); 42 | 43 | if ($responseObject != null) { 44 | // Get the status code from response 45 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 46 | 47 | // Get the api response object from responseObject 48 | $presentationResponseObject = $responseObject->getObject(); 49 | 50 | if ($presentationResponseObject != null) { 51 | // Check if the expected CreateDocumentResponse instance is received 52 | if ($presentationResponseObject instanceof CreateDocumentResponse) { 53 | $presentationId = $presentationResponseObject->getDocumentId(); 54 | 55 | echo "\nPresentation ID to be deleted - " . $presentationId . "\n"; 56 | 57 | $deleteApiResponse = $sdkOperations->deletePresentation($presentationId); 58 | 59 | if ($deleteApiResponse != null) { 60 | // Get the status code from response 61 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 62 | 63 | // Get the api response object from responseObject 64 | $deleteResponseObject = $deleteApiResponse->getObject(); 65 | 66 | if ($deleteResponseObject != null) { 67 | // Check if the expected CreateDocumentResponse instance is received 68 | if ($deleteResponseObject instanceof FileDeleteSuccessResponse) { 69 | echo "\nPresentation delete status : - " . $deleteResponseObject->getDocDelete() . "\n"; 70 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 71 | echo "\nInvalid configuration exception." . "\n"; 72 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 73 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 74 | if ( $deleteResponseObject->getKeyName() ) { 75 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 76 | } 77 | if ( $deleteResponseObject->getParameterName() ) { 78 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 79 | } 80 | } else { 81 | echo "\nRequest not completed successfully\n"; 82 | } 83 | } 84 | } 85 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 86 | echo "\nInvalid configuration exception." . "\n"; 87 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 88 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 89 | if ( $presentationResponseObject->getKeyName() ) { 90 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 91 | } 92 | if ( $presentationResponseObject->getParameterName() ) { 93 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 94 | } 95 | } else { 96 | echo "\nRequest not completed successfully\n"; 97 | } 98 | } 99 | } 100 | } catch (Exception $error) { 101 | echo "\nException while running sample code: " . $error . "\n"; 102 | } 103 | } 104 | 105 | public static function initializeSdk() { 106 | 107 | # Update the api domain based on in which data center user register your apikey 108 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 109 | $environment = new Production("https://api.office-integrator.com"); 110 | # User your apikey that you have in office integrator dashboard 111 | //Update this apikey with your own apikey signed up in office inetgrator service 112 | $authBuilder = new AuthBuilder(); 113 | $authentication = new Authentication(); 114 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 115 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 116 | $tokens = [ $authBuilder->build() ]; 117 | 118 | # Configure a proper file path to write the sdk logs 119 | $logger = (new LogBuilder()) 120 | ->level(Levels::INFO) 121 | ->filePath("./app.log") 122 | ->build(); 123 | 124 | (new InitializeBuilder()) 125 | ->environment($environment) 126 | ->tokens($tokens) 127 | ->logger($logger) 128 | ->initialize(); 129 | 130 | echo "SDK initialized successfully.\n"; 131 | } 132 | } 133 | 134 | DeletePresentation::execute(); 135 | 136 | -------------------------------------------------------------------------------- /spreadsheet-apis/DeleteSpreadsheetSession.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 37 | $documentInfo->setDocumentName("New Spreadsheet"); 38 | 39 | $parameters->setDocumentInfo($documentInfo); 40 | 41 | $responseObject = $sdkOperations->createSheet($parameters); 42 | 43 | if ($responseObject != null) { 44 | // Get the status code from response 45 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 46 | 47 | // Get the api response object from responseObject 48 | $spreadsheetResponseObject = $responseObject->getObject(); 49 | 50 | if ($spreadsheetResponseObject != null) { 51 | // Check if the expected CreateDocumentResponse instance is received 52 | if ($spreadsheetResponseObject instanceof CreateSheetResponse) { 53 | $spreadsheetSessionId = $spreadsheetResponseObject->getSessionId(); 54 | 55 | echo "\nSpreadsheet Session ID to be deleted - " . $spreadsheetSessionId . "\n"; 56 | 57 | $deleteApiResponse = $sdkOperations->deleteSheetSession($spreadsheetSessionId); 58 | 59 | if ($deleteApiResponse != null) { 60 | // Get the status code from response 61 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 62 | 63 | // Get the api response object from responseObject 64 | $deleteResponseObject = $deleteApiResponse->getObject(); 65 | 66 | if ($deleteResponseObject != null) { 67 | // Check if the expected SessionDeleteSuccessResponse instance is received 68 | if ($deleteResponseObject instanceof SessionDeleteSuccessResponse) { 69 | echo "\nSpreadsheet Session delete status : - " . $deleteResponseObject->getSessionDelete() . "\n"; 70 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 71 | echo "\nInvalid configuration exception." . "\n"; 72 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 73 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 74 | if ( $deleteResponseObject->getKeyName() ) { 75 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 76 | } 77 | if ( $deleteResponseObject->getParameterName() ) { 78 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 79 | } 80 | } else { 81 | echo "\nRequest not completed successfully\n"; 82 | } 83 | } 84 | } 85 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 86 | echo "\nInvalid configuration exception." . "\n"; 87 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 88 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 89 | if ( $spreadsheetResponseObject->getKeyName() ) { 90 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 91 | } 92 | if ( $spreadsheetResponseObject->getParameterName() ) { 93 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 94 | } 95 | } else { 96 | echo "\nRequest not completed successfully\n"; 97 | } 98 | } 99 | } 100 | } catch (Exception $error) { 101 | echo "\nException while running sample code: " . $error . "\n"; 102 | } 103 | } 104 | 105 | public static function initializeSdk() { 106 | 107 | # Update the api domain based on in which data center user register your apikey 108 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 109 | $environment = new Production("https://api.office-integrator.com"); 110 | # User your apikey that you have in office integrator dashboard 111 | //Update this apikey with your own apikey signed up in office inetgrator service 112 | $authBuilder = new AuthBuilder(); 113 | $authentication = new Authentication(); 114 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 115 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 116 | $tokens = [ $authBuilder->build() ]; 117 | 118 | # Configure a proper file path to write the sdk logs 119 | $logger = (new LogBuilder()) 120 | ->level(Levels::INFO) 121 | ->filePath("./app.log") 122 | ->build(); 123 | 124 | (new InitializeBuilder()) 125 | ->environment($environment) 126 | ->tokens($tokens) 127 | ->logger($logger) 128 | ->initialize(); 129 | 130 | echo "SDK initialized successfully.\n"; 131 | } 132 | } 133 | 134 | DeleteSpreadsheetSession::execute(); 135 | 136 | -------------------------------------------------------------------------------- /presentation-apis/DeletePresentationSession.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 37 | $documentInfo->setDocumentName("New Presentation"); 38 | 39 | $parameters->setDocumentInfo($documentInfo); 40 | 41 | $responseObject = $sdkOperations->createPresentation($parameters); 42 | 43 | if ($responseObject != null) { 44 | // Get the status code from response 45 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 46 | 47 | // Get the api response object from responseObject 48 | $presentationResponseObject = $responseObject->getObject(); 49 | 50 | if ($presentationResponseObject != null) { 51 | // Check if the expected CreateDocumentResponse instance is received 52 | if ($presentationResponseObject instanceof CreateDocumentResponse) { 53 | $sessionId = $presentationResponseObject->getSessionId(); 54 | 55 | echo "\nPresentation Session ID to be deleted - " . $sessionId . "\n"; 56 | 57 | $deleteApiResponse = $sdkOperations->deletePresentationSession($sessionId); 58 | 59 | if ($deleteApiResponse != null) { 60 | // Get the status code from response 61 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 62 | 63 | // Get the api response object from responseObject 64 | $deleteResponseObject = $deleteApiResponse->getObject(); 65 | 66 | if ($deleteResponseObject != null) { 67 | // Check if the expected CreateDocumentResponse instance is received 68 | if ($deleteResponseObject instanceof SessionDeleteSuccessResponse) { 69 | echo "\nPresentation session delete status : - " . $deleteResponseObject->getSessionDelete() . "\n"; 70 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 71 | echo "\nInvalid configuration exception." . "\n"; 72 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 73 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 74 | if ( $deleteResponseObject->getKeyName() ) { 75 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 76 | } 77 | if ( $deleteResponseObject->getParameterName() ) { 78 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 79 | } 80 | } else { 81 | echo "\nRequest not completed successfully\n"; 82 | } 83 | } 84 | } 85 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 86 | echo "\nInvalid configuration exception." . "\n"; 87 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 88 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 89 | if ( $presentationResponseObject->getKeyName() ) { 90 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 91 | } 92 | if ( $presentationResponseObject->getParameterName() ) { 93 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 94 | } 95 | } else { 96 | echo "\nRequest not completed successfully\n"; 97 | } 98 | } 99 | } 100 | } catch (Exception $error) { 101 | echo "\nException while running sample code: " . $error . "\n"; 102 | } 103 | } 104 | 105 | public static function initializeSdk() { 106 | 107 | # Update the api domain based on in which data center user register your apikey 108 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 109 | $environment = new Production("https://api.office-integrator.com"); 110 | # User your apikey that you have in office integrator dashboard 111 | //Update this apikey with your own apikey signed up in office inetgrator service 112 | $authBuilder = new AuthBuilder(); 113 | $authentication = new Authentication(); 114 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 115 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 116 | $tokens = [ $authBuilder->build() ]; 117 | 118 | # Configure a proper file path to write the sdk logs 119 | $logger = (new LogBuilder()) 120 | ->level(Levels::INFO) 121 | ->filePath("./app.log") 122 | ->build(); 123 | 124 | (new InitializeBuilder()) 125 | ->environment($environment) 126 | ->tokens($tokens) 127 | ->logger($logger) 128 | ->initialize(); 129 | 130 | echo "SDK initialized successfully.\n"; 131 | } 132 | } 133 | 134 | DeletePresentationSession::execute(); 135 | 136 | -------------------------------------------------------------------------------- /document-apis/DeleteDocument.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 37 | $documentInfo->setDocumentName("New Document"); 38 | 39 | $createDocumentParameters->setDocumentInfo($documentInfo); 40 | 41 | echo "\nCreating a document to demonstrate document delete api"; 42 | 43 | $responseObject = $sdkOperations->createDocument($createDocumentParameters); 44 | 45 | if ($responseObject != null) { 46 | // Get the status code from response 47 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 48 | 49 | // Get the api response object from responseObject 50 | $writerResponseObject = $responseObject->getObject(); 51 | 52 | if ($writerResponseObject != null) { 53 | // Check if the expected CreateDocumentResponse instance is received 54 | if ($writerResponseObject instanceof CreateDocumentResponse) { 55 | $documentId = $writerResponseObject->getDocumentId(); 56 | 57 | echo "\nDocument ID to be deleted - " . $documentId . "\n"; 58 | 59 | $deleteApiResponse = $sdkOperations->deleteDocument($documentId); 60 | 61 | if ($deleteApiResponse != null) { 62 | // Get the status code from response 63 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 64 | 65 | // Get the api response object from responseObject 66 | $deleteResponseObject = $deleteApiResponse->getObject(); 67 | 68 | if ($deleteResponseObject != null) { 69 | // Check if the expected CreateDocumentResponse instance is received 70 | if ($deleteResponseObject instanceof DocumentDeleteSuccessResponse) { 71 | echo "\nDocument delete status : - " . $deleteResponseObject->getDocumentDeleted() . "\n"; 72 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 73 | echo "\nInvalid configuration exception." . "\n"; 74 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 75 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 76 | if ( $deleteResponseObject->getKeyName() ) { 77 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 78 | } 79 | if ( $deleteResponseObject->getParameterName() ) { 80 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 81 | } 82 | } else { 83 | echo "\nRequest not completed successfully\n"; 84 | } 85 | } 86 | } 87 | 88 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 89 | echo "\nInvalid configuration exception." . "\n"; 90 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 91 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 92 | if ( $writerResponseObject->getKeyName() ) { 93 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 94 | } 95 | if ( $writerResponseObject->getParameterName() ) { 96 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 97 | } 98 | } else { 99 | echo "\nRequest not completed successfully\n"; 100 | } 101 | } 102 | } 103 | } catch (Exception $error) { 104 | echo "\nException while running sample code: " . $error . "\n"; 105 | } 106 | } 107 | 108 | public static function initializeSdk() { 109 | 110 | # Update the api domain based on in which data center user register your apikey 111 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 112 | $environment = new Production("https://api.office-integrator.com"); 113 | # User your apikey that you have in office integrator dashboard 114 | //Update this apikey with your own apikey signed up in office inetgrator service 115 | $authBuilder = new AuthBuilder(); 116 | $authentication = new Authentication(); 117 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 118 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 119 | $tokens = [ $authBuilder->build() ]; 120 | 121 | # Configure a proper file path to write the sdk logs 122 | $logger = (new LogBuilder()) 123 | ->level(Levels::INFO) 124 | ->filePath("./app.log") 125 | ->build(); 126 | 127 | (new InitializeBuilder()) 128 | ->environment($environment) 129 | ->tokens($tokens) 130 | ->logger($logger) 131 | ->initialize(); 132 | 133 | echo "SDK initialized successfully.\n"; 134 | } 135 | } 136 | 137 | DeleteDocument::execute(); 138 | 139 | -------------------------------------------------------------------------------- /document-apis/DeleteDocumentSession.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 37 | $documentInfo->setDocumentName("New Document"); 38 | 39 | $createDocumentParameters->setDocumentInfo($documentInfo); 40 | 41 | echo "\nCreating a document to demonstrate document session delete api"; 42 | 43 | $responseObject = $sdkOperations->createDocument($createDocumentParameters); 44 | 45 | if ($responseObject != null) { 46 | // Get the status code from response 47 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 48 | 49 | // Get the api response object from responseObject 50 | $writerResponseObject = $responseObject->getObject(); 51 | 52 | if ($writerResponseObject != null) { 53 | // Check if the expected CreateDocumentResponse instance is received 54 | if ($writerResponseObject instanceof CreateDocumentResponse) { 55 | $sessionId = $writerResponseObject->getSessionId(); 56 | 57 | echo "\nDocument Session ID to be deleted - " . $sessionId . "\n"; 58 | 59 | $deleteApiResponse = $sdkOperations->deleteSession($sessionId); 60 | 61 | if ($deleteApiResponse != null) { 62 | // Get the status code from response 63 | echo "\nDelete API Response Status Code: " . $deleteApiResponse->getStatusCode() . "\n"; 64 | 65 | // Get the api response object from responseObject 66 | $deleteResponseObject = $deleteApiResponse->getObject(); 67 | 68 | if ($deleteResponseObject != null) { 69 | // Check if the expected CreateDocumentResponse instance is received 70 | if ($deleteResponseObject instanceof DocumentSessionDeleteSuccessResponse) { 71 | echo "\nDocument Session delete status : - " . $deleteResponseObject->getSessionDeleted() . "\n"; 72 | } elseif ($deleteResponseObject instanceof InvalidConfigurationException) { 73 | echo "\nInvalid configuration exception." . "\n"; 74 | echo "\nError Code - " . $deleteResponseObject->getCode() . "\n"; 75 | echo "\nError Message - " . $deleteResponseObject->getMessage() . "\n"; 76 | if ( $deleteResponseObject->getKeyName() ) { 77 | echo "\nError Key Name - " . $deleteResponseObject->getKeyName() . "\n"; 78 | } 79 | if ( $deleteResponseObject->getParameterName() ) { 80 | echo "\nError Parameter Name - " . $deleteResponseObject->getParameterName() . "\n"; 81 | } 82 | } else { 83 | echo "\nRequest not completed successfully\n"; 84 | } 85 | } 86 | } 87 | 88 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 89 | echo "\nInvalid configuration exception." . "\n"; 90 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 91 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 92 | if ( $writerResponseObject->getKeyName() ) { 93 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 94 | } 95 | if ( $writerResponseObject->getParameterName() ) { 96 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 97 | } 98 | } else { 99 | echo "\nRequest not completed successfully\n"; 100 | } 101 | } 102 | } 103 | } catch (Exception $error) { 104 | echo "\nException while running sample code: " . $error . "\n"; 105 | } 106 | } 107 | 108 | public static function initializeSdk() { 109 | 110 | # Update the api domain based on in which data center user register your apikey 111 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 112 | $environment = new Production("https://api.office-integrator.com"); 113 | # User your apikey that you have in office integrator dashboard 114 | //Update this apikey with your own apikey signed up in office inetgrator service 115 | $authBuilder = new AuthBuilder(); 116 | $authentication = new Authentication(); 117 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 118 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 119 | $tokens = [ $authBuilder->build() ]; 120 | 121 | # Configure a proper file path to write the sdk logs 122 | $logger = (new LogBuilder()) 123 | ->level(Levels::INFO) 124 | ->filePath("./app.log") 125 | ->build(); 126 | 127 | (new InitializeBuilder()) 128 | ->environment($environment) 129 | ->tokens($tokens) 130 | ->logger($logger) 131 | ->initialize(); 132 | 133 | echo "SDK initialized successfully.\n"; 134 | } 135 | } 136 | 137 | DeleteDocumentSession::execute(); 138 | 139 | -------------------------------------------------------------------------------- /pdf-apis/EditPdf.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 38 | 39 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 40 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Zoho_Show.pptx"; 41 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 42 | 43 | $documentInfo = new DocumentInfo(); 44 | 45 | // Time value used to generate a unique document every time. You can replace it based on your application. 46 | $documentInfo->setDocumentId(strval(time())); 47 | $documentInfo->setDocumentName("EventForm.pdf"); 48 | 49 | $parameters->setDocumentInfo($documentInfo); 50 | 51 | $userInfo = new UserInfo(); 52 | 53 | $userInfo->setUserId("100"); 54 | $userInfo->setDisplayName("User 1"); 55 | 56 | $parameters->setUserInfo($userInfo); 57 | 58 | $editorSettings = new PdfEditorSettings(); 59 | 60 | $editorSettings->setUnit("in"); 61 | $editorSettings->setLanguage("en"); 62 | 63 | $parameters->setEditorSettings($editorSettings); 64 | 65 | $callbackSettings = new CallbackSettings(); 66 | $saveUrlParams = array(); 67 | 68 | $saveUrlParams["param1"] = "value1"; 69 | $saveUrlParams["param2"] = "value2"; 70 | 71 | $callbackSettings->setSaveUrlParams($saveUrlParams); 72 | 73 | $saveUrlHeaders = array(); 74 | 75 | $saveUrlHeaders["header1"] = "value1"; 76 | $saveUrlHeaders["header2"] = "value2"; 77 | 78 | $callbackSettings->setSaveUrlHeaders($saveUrlHeaders); 79 | 80 | $callbackSettings->setRetries(1); 81 | $callbackSettings->setSaveFormat("pdf"); 82 | $callbackSettings->setHttpMethodType("post"); 83 | $callbackSettings->setTimeout(100000); 84 | $callbackSettings->setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286"); 85 | 86 | $parameters->setCallbackSettings($callbackSettings); 87 | 88 | $responseObject = $sdkOperations->editPdf($parameters); 89 | 90 | if ($responseObject != null) { 91 | // Get the status code from response 92 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 93 | 94 | // Get the api response object from responseObject 95 | $pdfResponseObj = $responseObject->getObject(); 96 | 97 | if ($pdfResponseObj != null) { 98 | // Check if the expected CreateDocumentResponse instance is received 99 | if ($pdfResponseObj instanceof CreateDocumentResponse) { 100 | echo "\nPdf ID - " . $pdfResponseObj->getDocumentId() . "\n"; 101 | echo "\nPdf Session ID - " . $pdfResponseObj->getSessionId() . "\n"; 102 | echo "\nPdf Session URL - " . $pdfResponseObj->getDocumentUrl() . "\n"; 103 | echo "\nPdf Session save URL - " . $pdfResponseObj->getSaveUrl() . "\n"; 104 | echo "\nPdf delete URL - " . $pdfResponseObj->getDocumentDeleteUrl() . "\n"; 105 | echo "\nPdf Session delete URL - " . $pdfResponseObj->getSessionDeleteUrl() . "\n"; 106 | } elseif ($pdfResponseObj instanceof InvalidConfigurationException) { 107 | echo "\nInvalid configuration exception." . "\n"; 108 | echo "\nError Code - " . $pdfResponseObj->getCode() . "\n"; 109 | echo "\nError Message - " . $pdfResponseObj->getMessage() . "\n"; 110 | if ( $pdfResponseObj->getKeyName() ) { 111 | echo "\nError Key Name - " . $pdfResponseObj->getKeyName() . "\n"; 112 | } 113 | if ( $pdfResponseObj->getParameterName() ) { 114 | echo "\nError Parameter Name - " . $pdfResponseObj->getParameterName() . "\n"; 115 | } 116 | } else { 117 | echo "\nRequest not completed successfully\n"; 118 | } 119 | } 120 | } 121 | } catch (Exception $error) { 122 | echo "\nException while running sample code: " . $error . "\n"; 123 | } 124 | } 125 | 126 | public static function initializeSdk() { 127 | 128 | # Update the api domain based on in which data center user register your apikey 129 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 130 | $environment = new Production("https://api.office-integrator.com"); 131 | # User your apikey that you have in office integrator dashboard 132 | //Update this apikey with your own apikey signed up in office inetgrator service 133 | $authBuilder = new AuthBuilder(); 134 | $authentication = new Authentication(); 135 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 136 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 137 | $tokens = [ $authBuilder->build() ]; 138 | 139 | # Configure a proper file path to write the sdk logs 140 | $logger = (new LogBuilder()) 141 | ->level(Levels::INFO) 142 | ->filePath("./app.log") 143 | ->build(); 144 | 145 | (new InitializeBuilder()) 146 | ->environment($environment) 147 | ->tokens($tokens) 148 | ->logger($logger) 149 | ->initialize(); 150 | 151 | echo "SDK initialized successfully.\n"; 152 | } 153 | } 154 | 155 | EditPdf::execute(); 156 | 157 | -------------------------------------------------------------------------------- /presentation-apis/CreatePresentation.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 40 | $documentInfo->setDocumentName("New Presentation"); 41 | 42 | $parameters->setDocumentInfo($documentInfo); 43 | 44 | # Optional Configuration 45 | $userInfo = new UserInfo(); 46 | 47 | $userInfo->setUserId("100"); 48 | $userInfo->setDisplayName("User 1"); 49 | 50 | $parameters->setUserInfo($userInfo); 51 | 52 | # Optional Configuration 53 | $editorSettings = new ZohoShowEditorSettings(); 54 | 55 | $editorSettings->setLanguage("en"); 56 | 57 | $parameters->setEditorSettings($editorSettings); 58 | 59 | # Optional Configuration 60 | $permissions = array(); 61 | 62 | $permissions["document.export"] = "true"; 63 | $permissions["document.print"] = "true"; 64 | $permissions["document.edit"] = "true"; 65 | 66 | $parameters->setPermissions($permissions); 67 | 68 | # Optional Configuration 69 | $callbackSettings = new CallbackSettings(); 70 | $saveUrlParams = array(); 71 | 72 | $saveUrlParams["param1"] = "value1"; 73 | $saveUrlParams["param2"] = "value2"; 74 | 75 | $callbackSettings->setSaveUrlParams($saveUrlParams); 76 | 77 | $saveUrlHeaders = array(); 78 | 79 | $saveUrlHeaders["header1"] = "value1"; 80 | $saveUrlHeaders["header2"] = "value2"; 81 | 82 | //$callbackSettings->setSaveUrlHeaders($saveUrlHeaders); 83 | 84 | $callbackSettings->setRetries(1); 85 | $callbackSettings->setSaveFormat("pptx"); 86 | $callbackSettings->setHttpMethodType("post"); 87 | $callbackSettings->setTimeout(100000); 88 | $callbackSettings->setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286"); 89 | 90 | $parameters->setCallbackSettings($callbackSettings); 91 | 92 | $responseObject = $sdkOperations->createPresentation($parameters); 93 | 94 | if ($responseObject != null) { 95 | // Get the status code from response 96 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 97 | 98 | // Get the api response object from responseObject 99 | $presentationResponseObject = $responseObject->getObject(); 100 | 101 | if ($presentationResponseObject != null) { 102 | // Check if the expected CreateDocumentResponse instance is received 103 | if ($presentationResponseObject instanceof CreateDocumentResponse) { 104 | echo "\nDocument ID - " . $presentationResponseObject->getDocumentId() . "\n"; 105 | echo "\nDocument session ID - " . $presentationResponseObject->getSessionId() . "\n"; 106 | echo "\nDocument session URL - " . $presentationResponseObject->getDocumentUrl() . "\n"; 107 | echo "\nDocument save URL - " . $presentationResponseObject->getSaveUrl() . "\n"; 108 | echo "\nDocument delete URL - " . $presentationResponseObject->getDocumentDeleteUrl() . "\n"; 109 | echo "\nDocument session delete URL - " . $presentationResponseObject->getSessionDeleteUrl() . "\n"; 110 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 111 | echo "\nInvalid configuration exception." . "\n"; 112 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 113 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 114 | if ( $presentationResponseObject->getKeyName() ) { 115 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 116 | } 117 | if ( $presentationResponseObject->getParameterName() ) { 118 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 119 | } 120 | } else { 121 | echo "\nRequest not completed successfully\n"; 122 | } 123 | } 124 | } 125 | } catch (Exception $error) { 126 | echo "\nException while running sample code: " . $error . "\n"; 127 | } 128 | } 129 | 130 | public static function initializeSdk() { 131 | 132 | # Update the api domain based on in which data center user register your apikey 133 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 134 | $environment = new Production("https://api.office-integrator.com"); 135 | # User your apikey that you have in office integrator dashboard 136 | //Update this apikey with your own apikey signed up in office inetgrator service 137 | $authBuilder = new AuthBuilder(); 138 | $authentication = new Authentication(); 139 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 140 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 141 | $tokens = [ $authBuilder->build() ]; 142 | 143 | # Configure a proper file path to write the sdk logs 144 | $logger = (new LogBuilder()) 145 | ->level(Levels::INFO) 146 | ->filePath("./app.log") 147 | ->build(); 148 | 149 | (new InitializeBuilder()) 150 | ->environment($environment) 151 | ->tokens($tokens) 152 | ->logger($logger) 153 | ->initialize(); 154 | 155 | echo "SDK initialized successfully.\n"; 156 | } 157 | } 158 | 159 | CreatePresentation::execute(); 160 | 161 | -------------------------------------------------------------------------------- /document-apis/EditDocument.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 36 | 37 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 38 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Graphic-Design-Proposal.docx"; 39 | // $createDocumentParameters->setDocument(new StreamWrapper(null, null, $filePath)); 40 | 41 | # Optional Configuration - Add document meta in request to identify the file in Zoho Server 42 | $documentInfo = new DocumentInfo(); 43 | $currentTime = time(); 44 | 45 | $documentInfo->setDocumentName("New Document"); 46 | $documentInfo->setDocumentId($currentTime); 47 | 48 | $createDocumentParameters->setDocumentInfo($documentInfo); 49 | 50 | # Optional Configuration - Add User meta in request to identify the user in document session 51 | $userInfo = new UserInfo(); 52 | 53 | $userInfo->setUserId(100); 54 | $userInfo->setDisplayName("John"); 55 | 56 | $createDocumentParameters->setUserInfo($userInfo); 57 | 58 | # Optional Configuration - Set default settings for document while creating document itself. 59 | # It's applicable only for new documents. 60 | $documentDefaults = new DocumentDefaults(); 61 | 62 | $documentDefaults->getTrackChanges("enabled"); 63 | $documentDefaults->setLanguage("ta"); 64 | 65 | $createDocumentParameters->setDocumentDefaults($documentDefaults); 66 | 67 | # Optional Configuration 68 | $editorSettings = new EditorSettings(); 69 | 70 | $editorSettings->setUnit("in"); 71 | $editorSettings->setLanguage("en"); 72 | $editorSettings->setView("pageview"); 73 | 74 | $createDocumentParameters->setEditorSettings($editorSettings); 75 | 76 | # Optional Configuration 77 | $uiOptions = new UiOptions(); 78 | 79 | $uiOptions->setDarkMode("show"); 80 | $uiOptions->setFileMenu("show"); 81 | $uiOptions->setSaveButton("show"); 82 | $uiOptions->setChatPanel("show"); 83 | 84 | $createDocumentParameters->setUiOptions($uiOptions); 85 | 86 | # Optional Configuration 87 | $permissions = array(); 88 | 89 | $permissions["document.export"] = "true"; 90 | $permissions["document.print"] = "false"; 91 | $permissions["document.edit"] = "true"; 92 | $permissions["review.comment"] = "false"; 93 | $permissions["review.changes.resolve"] = "false"; 94 | $permissions["collab.chat"] = "false"; 95 | $permissions["document.pausecollaboration"] = "false"; 96 | $permissions["document.fill"] = "false"; 97 | 98 | $createDocumentParameters->setPermissions($permissions); 99 | 100 | # Optional Configuration - Add callback settings to configure. 101 | # how file needs to be received while saving the document 102 | $callbackSettings = new CallbackSettings(); 103 | $saveUrlParams = array(); 104 | 105 | $saveUrlHeaders["param1"] = "value1"; 106 | $saveUrlHeaders["param2"] = "value2"; 107 | 108 | $callbackSettings->setSaveUrlParams($saveUrlParams); 109 | 110 | $saveUrlHeaders = array(); 111 | 112 | $saveUrlHeaders["header1"] = "value1"; 113 | $saveUrlHeaders["header2"] = "value2"; 114 | 115 | $callbackSettings->setSaveUrlHeaders($saveUrlHeaders); 116 | 117 | $callbackSettings->setRetries(1); 118 | $callbackSettings->setSaveFormat("zdoc"); 119 | $callbackSettings->setHttpMethodType("post"); 120 | $callbackSettings->setTimeout(100000); 121 | $callbackSettings->setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286"); 122 | 123 | $createDocumentParameters->setCallbackSettings($callbackSettings); 124 | 125 | $response = $v1Operations->createDocument($createDocumentParameters); 126 | 127 | if($response != null) 128 | { 129 | //Get the status code from response 130 | echo("Status code " . $response->getStatusCode() . "\n"); 131 | 132 | //Get object from response 133 | $responseHandler = $response->getObject(); 134 | 135 | if($responseHandler instanceof CreateDocumentResponse) 136 | { 137 | echo("\nDocument ID - " . $responseHandler->getDocumentId() . "\n"); 138 | echo("Document Session ID - " . $responseHandler->getSessionId() . "\n"); 139 | echo("Document Session URL - " . $responseHandler->getDocumentUrl() . "\n"); 140 | echo("Document Session Delete URL - " . $responseHandler->getSessionDeleteUrl() . "\n"); 141 | echo("Document Save URL - " . $responseHandler->getSaveUrl() . "\n"); 142 | echo("Document Delete URL - " . $responseHandler->getDocumentDeleteUrl() . "\n"); 143 | } 144 | } 145 | } 146 | 147 | public static function initializeSdk() { 148 | 149 | # Update the api domain based on in which data center user register your apikey 150 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 151 | $environment = new Production("https://api.office-integrator.com"); 152 | # User your apikey that you have in office integrator dashboard 153 | //Update this apikey with your own apikey signed up in office inetgrator service 154 | $authBuilder = new AuthBuilder(); 155 | $authentication = new Authentication(); 156 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 157 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 158 | $tokens = [ $authBuilder->build() ]; 159 | 160 | # Configure a proper file path to write the sdk logs 161 | $logger = (new LogBuilder()) 162 | ->level(Levels::INFO) 163 | ->filePath("./app.log") 164 | ->build(); 165 | 166 | (new InitializeBuilder()) 167 | ->environment($environment) 168 | ->tokens($tokens) 169 | ->logger($logger) 170 | ->initialize(); 171 | 172 | echo "SDK initialized successfully.\n"; 173 | } 174 | } 175 | 176 | EditDocument::execute(); 177 | 178 | ?> -------------------------------------------------------------------------------- /spreadsheet-apis/CreateSpreadsheet.php: -------------------------------------------------------------------------------- 1 | setDocumentId(strval(time())); 41 | $documentInfo->setDocumentName("New Document"); 42 | 43 | $parameters->setDocumentInfo($documentInfo); 44 | 45 | # Optional Configuration 46 | $userInfo = new SheetUserSettings(); 47 | 48 | $userInfo->setDisplayName("User 1"); 49 | 50 | $parameters->setUserInfo($userInfo); 51 | 52 | # Optional Configuration 53 | $editorSettings = new SheetEditorSettings(); 54 | 55 | $editorSettings->setLanguage("en"); 56 | 57 | $parameters->setEditorSettings($editorSettings); 58 | 59 | # Optional Configuration 60 | $uiOptions = new SheetUiOptions(); 61 | 62 | $uiOptions->setSaveButton("show"); 63 | 64 | $parameters->setUiOptions($uiOptions); 65 | 66 | # Optional Configuration 67 | $permissions = array(); 68 | 69 | $permissions["document.export"] = "true"; 70 | $permissions["document.print"] = "true"; 71 | $permissions["document.edit"] = "true"; 72 | 73 | $parameters->setPermissions($permissions); 74 | 75 | # Optional Configuration 76 | $callbackSettings = new SheetCallbackSettings(); 77 | $saveUrlParams = array(); 78 | 79 | $saveUrlParams["param1"] = "value1"; 80 | $saveUrlParams["param2"] = "value2"; 81 | 82 | $callbackSettings->setSaveUrlParams($saveUrlParams); 83 | 84 | $saveUrlHeaders = array(); 85 | 86 | $saveUrlHeaders["header1"] = "value1"; 87 | $saveUrlHeaders["header2"] = "value2"; 88 | 89 | $callbackSettings->setSaveUrlHeaders($saveUrlHeaders); 90 | 91 | $callbackSettings->setSaveFormat("xlsx"); 92 | $callbackSettings->setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286"); 93 | 94 | $parameters->setCallbackSettings($callbackSettings); 95 | 96 | $responseObject = $sdkOperations->createSheet($parameters); 97 | 98 | if ($responseObject != null) { 99 | // Get the status code from response 100 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 101 | 102 | // Get the api response object from responseObject 103 | $spreadsheetResponseObject = $responseObject->getObject(); 104 | 105 | if ($spreadsheetResponseObject != null) { 106 | // Check if the expected CreateDocumentResponse instance is received 107 | if ($spreadsheetResponseObject instanceof CreateSheetResponse) { 108 | echo "\nDocument ID - " . $spreadsheetResponseObject->getDocumentId() . "\n"; 109 | echo "\nDocument session ID - " . $spreadsheetResponseObject->getSessionId() . "\n"; 110 | echo "\nDocument session URL - " . $spreadsheetResponseObject->getDocumentUrl() . "\n"; 111 | echo "\nDocument session grid view URL - " . $spreadsheetResponseObject->getDocumentUrl() . "\n"; 112 | echo "\nDocument save URL - " . $spreadsheetResponseObject->getSaveUrl() . "\n"; 113 | echo "\nDocument delete URL - " . $spreadsheetResponseObject->getDocumentDeleteUrl() . "\n"; 114 | echo "\nDocument session delete URL - " . $spreadsheetResponseObject->getSessionDeleteUrl() . "\n"; 115 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 116 | echo "\nInvalid configuration exception." . "\n"; 117 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 118 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 119 | if ( $spreadsheetResponseObject->getKeyName() ) { 120 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 121 | } 122 | if ( $spreadsheetResponseObject->getParameterName() ) { 123 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 124 | } 125 | } else { 126 | echo "\nRequest not completed successfully\n"; 127 | } 128 | } 129 | } 130 | } catch (Exception $error) { 131 | echo "\nException while running sample code: " . $error . "\n"; 132 | } 133 | } 134 | 135 | public static function initializeSdk() { 136 | 137 | # Update the api domain based on in which data center user register your apikey 138 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 139 | $environment = new Production("https://api.office-integrator.com"); 140 | # User your apikey that you have in office integrator dashboard 141 | //Update this apikey with your own apikey signed up in office inetgrator service 142 | $authBuilder = new AuthBuilder(); 143 | $authentication = new Authentication(); 144 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 145 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 146 | $tokens = [ $authBuilder->build() ]; 147 | 148 | # Configure a proper file path to write the sdk logs 149 | $logger = (new LogBuilder()) 150 | ->level(Levels::INFO) 151 | ->filePath("./app.log") 152 | ->build(); 153 | 154 | (new InitializeBuilder()) 155 | ->environment($environment) 156 | ->tokens($tokens) 157 | ->logger($logger) 158 | ->initialize(); 159 | 160 | echo "SDK initialized successfully.\n"; 161 | } 162 | } 163 | 164 | CreateSpreadsheet::execute(); 165 | 166 | -------------------------------------------------------------------------------- /pdf-apis/GetPdfDocumentDetails.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 34 | 35 | $responseObject = $sdkOperations->editPdf($parameters); 36 | 37 | if ($responseObject != null) { 38 | // Get the status code from response 39 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 40 | 41 | // Get the api response object from responseObject 42 | $writerResponseObject = $responseObject->getObject(); 43 | 44 | if ($writerResponseObject != null) { 45 | // Check if the expected CreateDocumentResponse instance is received 46 | if ($writerResponseObject instanceof CreateDocumentResponse) { 47 | $documentId = $writerResponseObject->getDocumentId(); 48 | 49 | echo "\nCreated Document ID : " . $documentId . "\n"; 50 | 51 | $documentDetailsResponse = $sdkOperations->getPdfDocumentInfo($documentId); 52 | 53 | if ($documentDetailsResponse != null) { 54 | // Get the status code from response 55 | echo "\nStatus Code: " . $documentDetailsResponse->getStatusCode() . "\n"; 56 | 57 | // Get the api response object from responseObject 58 | $documentDetailsResponseObj = $documentDetailsResponse->getObject(); 59 | 60 | if ($documentDetailsResponseObj != null) { 61 | // Check if the expected CreateDocumentResponse instance is received 62 | if ($documentDetailsResponseObj instanceof DocumentMeta) { 63 | echo "\nPdf Document ID : - " . $documentDetailsResponseObj->getDocumentId() . "\n"; 64 | echo "\nPdf Document Name : - " . $documentDetailsResponseObj->getDocumentName() . "\n"; 65 | echo "\nPdf Document Type : - " . $documentDetailsResponseObj->getDocumentType() . "\n"; 66 | echo "\nPdf Document Collaborators Count :" . $documentDetailsResponseObj->getCollaboratorsCount() . "\n"; 67 | echo "\nPdf Document Created Time : - " . $documentDetailsResponseObj->getCreatedTime() . "\n"; 68 | echo "\nPdf Document Created Timestamp : - " . $documentDetailsResponseObj->getCreatedTimeMs() . "\n"; 69 | echo "\nPdf Document Expiry Time : - " . $documentDetailsResponseObj->getExpiresOn() . "\n"; 70 | echo "\nPdf Document Expiry Timestamp : - " . $documentDetailsResponseObj->getExpiresOnMs() . "\n"; 71 | } elseif ($documentDetailsResponseObj instanceof InvalidConfigurationException) { 72 | echo "\nInvalid configuration exception." . "\n"; 73 | echo "\nError Code - " . $documentDetailsResponseObj->getCode() . "\n"; 74 | echo "\nError Message - " . $documentDetailsResponseObj->getMessage() . "\n"; 75 | if ( $documentDetailsResponseObj->getKeyName() ) { 76 | echo "\nError Key Name - " . $documentDetailsResponseObj->getKeyName() . "\n"; 77 | } 78 | if ( $documentDetailsResponseObj->getParameterName() ) { 79 | echo "\nError Parameter Name - " . $documentDetailsResponseObj->getParameterName() . "\n"; 80 | } 81 | } else { 82 | echo "\nRequest not completed successfully\n"; 83 | } 84 | } 85 | } 86 | 87 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 88 | echo "\nInvalid configuration exception." . "\n"; 89 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 90 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 91 | if ( $writerResponseObject->getKeyName() ) { 92 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 93 | } 94 | if ( $writerResponseObject->getParameterName() ) { 95 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 96 | } 97 | } else { 98 | echo "\nRequest not completed successfully\n"; 99 | } 100 | } 101 | } 102 | } catch (Exception $error) { 103 | echo "\nException while running sample code: " . $error . "\n"; 104 | } 105 | } 106 | 107 | public static function initializeSdk() { 108 | 109 | # Update the api domain based on in which data center user register your apikey 110 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 111 | $environment = new Production("https://api.office-integrator.com"); 112 | # User your apikey that you have in office integrator dashboard 113 | //Update this apikey with your own apikey signed up in office inetgrator service 114 | $authBuilder = new AuthBuilder(); 115 | $authentication = new Authentication(); 116 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 117 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 118 | $tokens = [ $authBuilder->build() ]; 119 | 120 | # Configure a proper file path to write the sdk logs 121 | $logger = (new LogBuilder()) 122 | ->level(Levels::INFO) 123 | ->filePath("./app.log") 124 | ->build(); 125 | 126 | (new InitializeBuilder()) 127 | ->environment($environment) 128 | ->tokens($tokens) 129 | ->logger($logger) 130 | ->initialize(); 131 | 132 | echo "SDK initialized successfully.\n"; 133 | } 134 | } 135 | 136 | GetPdfDocumentDetails::execute(); 137 | -------------------------------------------------------------------------------- /presentation-apis/EditPresentation.php: -------------------------------------------------------------------------------- 1 | setUrl($url); 38 | 39 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 40 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Zoho_Show.pptx"; 41 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 42 | 43 | $documentInfo = new DocumentInfo(); 44 | 45 | // Time value used to generate a unique document every time. You can replace it based on your application. 46 | $documentInfo->setDocumentId(strval(time())); 47 | $documentInfo->setDocumentName("New Presentation"); 48 | 49 | $parameters->setDocumentInfo($documentInfo); 50 | 51 | $userInfo = new UserInfo(); 52 | 53 | $userInfo->setUserId("100"); 54 | $userInfo->setDisplayName("User 1"); 55 | 56 | $parameters->setUserInfo($userInfo); 57 | 58 | $editorSettings = new ZohoShowEditorSettings(); 59 | 60 | $editorSettings->setLanguage("en"); 61 | 62 | $parameters->setEditorSettings($editorSettings); 63 | 64 | $permissions = array(); 65 | 66 | $permissions["document.export"] = "true"; 67 | $permissions["document.print"] = "true"; 68 | $permissions["document.edit"] = "true"; 69 | 70 | $parameters->setPermissions($permissions); 71 | 72 | $callbackSettings = new CallbackSettings(); 73 | $saveUrlParams = array(); 74 | 75 | $saveUrlParams["param1"] = "value1"; 76 | $saveUrlParams["param2"] = "value2"; 77 | 78 | $callbackSettings->setSaveUrlParams($saveUrlParams); 79 | 80 | $saveUrlHeaders = array(); 81 | 82 | $saveUrlHeaders["header1"] = "value1"; 83 | $saveUrlHeaders["header2"] = "value2"; 84 | 85 | //$callbackSettings->setSaveUrlHeaders($saveUrlHeaders); 86 | 87 | $callbackSettings->setRetries(1); 88 | $callbackSettings->setSaveFormat("pptx"); 89 | $callbackSettings->setHttpMethodType("post"); 90 | $callbackSettings->setTimeout(100000); 91 | $callbackSettings->setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286"); 92 | 93 | $parameters->setCallbackSettings($callbackSettings); 94 | 95 | $responseObject = $sdkOperations->createPresentation($parameters); 96 | 97 | if ($responseObject != null) { 98 | // Get the status code from response 99 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 100 | 101 | // Get the api response object from responseObject 102 | $presentationResponseObject = $responseObject->getObject(); 103 | 104 | if ($presentationResponseObject != null) { 105 | // Check if the expected CreateDocumentResponse instance is received 106 | if ($presentationResponseObject instanceof CreateDocumentResponse) { 107 | echo "\nPresentation ID - " . $presentationResponseObject->getDocumentId() . "\n"; 108 | echo "\nPresentation session ID - " . $presentationResponseObject->getSessionId() . "\n"; 109 | echo "\nPresentation session URL - " . $presentationResponseObject->getDocumentUrl() . "\n"; 110 | echo "\nPresentation save URL - " . $presentationResponseObject->getSaveUrl() . "\n"; 111 | echo "\nPresentation delete URL - " . $presentationResponseObject->getDocumentDeleteUrl() . "\n"; 112 | echo "\nPresentation session delete URL - " . $presentationResponseObject->getSessionDeleteUrl() . "\n"; 113 | } elseif ($presentationResponseObject instanceof InvalidConfigurationException) { 114 | echo "\nInvalid configuration exception." . "\n"; 115 | echo "\nError Code - " . $presentationResponseObject->getCode() . "\n"; 116 | echo "\nError Message - " . $presentationResponseObject->getMessage() . "\n"; 117 | if ( $presentationResponseObject->getKeyName() ) { 118 | echo "\nError Key Name - " . $presentationResponseObject->getKeyName() . "\n"; 119 | } 120 | if ( $presentationResponseObject->getParameterName() ) { 121 | echo "\nError Parameter Name - " . $presentationResponseObject->getParameterName() . "\n"; 122 | } 123 | } else { 124 | echo "\nRequest not completed successfully\n"; 125 | } 126 | } 127 | } 128 | } catch (Exception $error) { 129 | echo "\nException while running sample code: " . $error . "\n"; 130 | } 131 | } 132 | 133 | public static function initializeSdk() { 134 | 135 | # Update the api domain based on in which data center user register your apikey 136 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 137 | $environment = new Production("https://api.office-integrator.com"); 138 | # User your apikey that you have in office integrator dashboard 139 | //Update this apikey with your own apikey signed up in office inetgrator service 140 | $authBuilder = new AuthBuilder(); 141 | $authentication = new Authentication(); 142 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 143 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 144 | $tokens = [ $authBuilder->build() ]; 145 | 146 | # Configure a proper file path to write the sdk logs 147 | $logger = (new LogBuilder()) 148 | ->level(Levels::INFO) 149 | ->filePath("./app.log") 150 | ->build(); 151 | 152 | (new InitializeBuilder()) 153 | ->environment($environment) 154 | ->tokens($tokens) 155 | ->logger($logger) 156 | ->initialize(); 157 | 158 | echo "SDK initialized successfully.\n"; 159 | } 160 | } 161 | 162 | EditPresentation::execute(); 163 | 164 | -------------------------------------------------------------------------------- /document-apis/GetDocumentDetails.php: -------------------------------------------------------------------------------- 1 | setUserId("1000"); 36 | $userInfo->setDisplayName("Prabakaran R"); 37 | 38 | $createDocumentParameters->setUserInfo($userInfo); 39 | 40 | echo "\nCreating a document to demonstrate get all document information api\n"; 41 | 42 | $responseObject = $sdkOperations->createDocument($createDocumentParameters); 43 | 44 | if ($responseObject != null) { 45 | // Get the status code from response 46 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 47 | 48 | // Get the api response object from responseObject 49 | $writerResponseObject = $responseObject->getObject(); 50 | 51 | if ($writerResponseObject != null) { 52 | // Check if the expected CreateDocumentResponse instance is received 53 | if ($writerResponseObject instanceof CreateDocumentResponse) { 54 | $documentId = $writerResponseObject->getDocumentId(); 55 | 56 | echo "\nCreated Document ID : " . $documentId . "\n"; 57 | 58 | $documentDetailsResponse = $sdkOperations->getDocumentInfo($documentId); 59 | 60 | if ($documentDetailsResponse != null) { 61 | // Get the status code from response 62 | echo "\nStatus Code: " . $documentDetailsResponse->getStatusCode() . "\n"; 63 | 64 | // Get the api response object from responseObject 65 | $documentDetailsResponseObj = $documentDetailsResponse->getObject(); 66 | 67 | if ($documentDetailsResponseObj != null) { 68 | // Check if the expected CreateDocumentResponse instance is received 69 | if ($documentDetailsResponseObj instanceof DocumentMeta) { 70 | echo "\nDocument ID : - " . $documentDetailsResponseObj->getDocumentId() . "\n"; 71 | echo "\nDocument Name : - " . $documentDetailsResponseObj->getDocumentName() . "\n"; 72 | echo "\nDocument Type : - " . $documentDetailsResponseObj->getDocumentType() . "\n"; 73 | echo "\nDocument Collaborators Count :" . $documentDetailsResponseObj->getCollaboratorsCount() . "\n"; 74 | echo "\nDocument Created Time : - " . $documentDetailsResponseObj->getCreatedTime() . "\n"; 75 | echo "\nDocument Created Timestamp : - " . $documentDetailsResponseObj->getCreatedTimeMs() . "\n"; 76 | echo "\nDocument Expiry Time : - " . $documentDetailsResponseObj->getExpiresOn() . "\n"; 77 | echo "\nDocument Expiry Timestamp : - " . $documentDetailsResponseObj->getExpiresOnMs() . "\n"; 78 | } elseif ($documentDetailsResponseObj instanceof InvalidConfigurationException) { 79 | echo "\nInvalid configuration exception." . "\n"; 80 | echo "\nError Code - " . $documentDetailsResponseObj->getCode() . "\n"; 81 | echo "\nError Message - " . $documentDetailsResponseObj->getMessage() . "\n"; 82 | if ( $documentDetailsResponseObj->getKeyName() ) { 83 | echo "\nError Key Name - " . $documentDetailsResponseObj->getKeyName() . "\n"; 84 | } 85 | if ( $documentDetailsResponseObj->getParameterName() ) { 86 | echo "\nError Parameter Name - " . $documentDetailsResponseObj->getParameterName() . "\n"; 87 | } 88 | } else { 89 | echo "\nRequest not completed successfully\n"; 90 | } 91 | } 92 | } 93 | 94 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 95 | echo "\nInvalid configuration exception." . "\n"; 96 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 97 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 98 | if ( $writerResponseObject->getKeyName() ) { 99 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 100 | } 101 | if ( $writerResponseObject->getParameterName() ) { 102 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 103 | } 104 | } else { 105 | echo "\nRequest not completed successfully\n"; 106 | } 107 | } 108 | } 109 | } catch (Exception $error) { 110 | echo "\nException while running sample code: " . $error . "\n"; 111 | } 112 | } 113 | 114 | public static function initializeSdk() { 115 | 116 | # Update the api domain based on in which data center user register your apikey 117 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 118 | $environment = new Production("https://api.office-integrator.com"); 119 | # User your apikey that you have in office integrator dashboard 120 | //Update this apikey with your own apikey signed up in office inetgrator service 121 | $authBuilder = new AuthBuilder(); 122 | $authentication = new Authentication(); 123 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 124 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 125 | $tokens = [ $authBuilder->build() ]; 126 | 127 | # Configure a proper file path to write the sdk logs 128 | $logger = (new LogBuilder()) 129 | ->level(Levels::INFO) 130 | ->filePath("./app.log") 131 | ->build(); 132 | 133 | (new InitializeBuilder()) 134 | ->environment($environment) 135 | ->tokens($tokens) 136 | ->logger($logger) 137 | ->initialize(); 138 | 139 | echo "SDK initialized successfully.\n"; 140 | } 141 | } 142 | 143 | GetDocumentDetails::execute(); 144 | 145 | -------------------------------------------------------------------------------- /spreadsheet-apis/EditSpreadsheet.php: -------------------------------------------------------------------------------- 1 | setUrl('https://demo.office-integrator.com/samples/sheet/Contact_List.xlsx'); 38 | 39 | // Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code. 40 | // $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Contact_List.xlsx"; 41 | // $parameters->setDocument(new StreamWrapper(null, null, $filePath)); 42 | 43 | # Optional Configuration 44 | $documentInfo = new DocumentInfo(); 45 | 46 | // Time value used to generate a unique document every time. You can replace it based on your application. 47 | $documentInfo->setDocumentId(strval(time())); 48 | $documentInfo->setDocumentName("New Document"); 49 | 50 | $parameters->setDocumentInfo($documentInfo); 51 | 52 | # Optional Configuration 53 | $userInfo = new SheetUserSettings(); 54 | 55 | $userInfo->setDisplayName("User 1"); 56 | 57 | $parameters->setUserInfo($userInfo); 58 | 59 | # Optional Configuration 60 | $editorSettings = new SheetEditorSettings(); 61 | 62 | $editorSettings->setLanguage("en"); 63 | 64 | $parameters->setEditorSettings($editorSettings); 65 | 66 | # Optional Configuration 67 | $uiOptions = new SheetUiOptions(); 68 | 69 | $uiOptions->setSaveButton("show"); 70 | 71 | $parameters->setUiOptions($uiOptions); 72 | 73 | $permissions = array(); 74 | 75 | $permissions["document.export"] = "true"; 76 | $permissions["document.print"] = "true"; 77 | $permissions["document.edit"] = "true"; 78 | 79 | $parameters->setPermissions($permissions); 80 | 81 | # Optional Configuration 82 | $callbackSettings = new SheetCallbackSettings(); 83 | $saveUrlParams = array(); 84 | 85 | $saveUrlParams["param1"] = "value1"; 86 | $saveUrlParams["param2"] = "value2"; 87 | 88 | $callbackSettings->setSaveUrlParams($saveUrlParams); 89 | 90 | $saveUrlHeaders = array(); 91 | 92 | $saveUrlHeaders["header1"] = "value1"; 93 | $saveUrlHeaders["header2"] = "value2"; 94 | 95 | $callbackSettings->setSaveUrlHeaders($saveUrlHeaders); 96 | 97 | $callbackSettings->setSaveFormat("xlsx"); 98 | $callbackSettings->setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286"); 99 | 100 | $parameters->setCallbackSettings($callbackSettings); 101 | 102 | $responseObject = $sdkOperations->createSheet($parameters); 103 | 104 | if ($responseObject != null) { 105 | // Get the status code from response 106 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 107 | 108 | // Get the api response object from responseObject 109 | $spreadsheetResponseObject = $responseObject->getObject(); 110 | 111 | if ($spreadsheetResponseObject != null) { 112 | // Check if the expected CreateDocumentResponse instance is received 113 | if ($spreadsheetResponseObject instanceof CreateSheetResponse) { 114 | echo "\nDocument ID - " . $spreadsheetResponseObject->getDocumentId() . "\n"; 115 | echo "\nDocument session ID - " . $spreadsheetResponseObject->getSessionId() . "\n"; 116 | echo "\nDocument session URL - " . $spreadsheetResponseObject->getDocumentUrl() . "\n"; 117 | echo "\nDocument session grid view URL - " . $spreadsheetResponseObject->getDocumentUrl() . "\n"; 118 | echo "\nDocument save URL - " . $spreadsheetResponseObject->getSaveUrl() . "\n"; 119 | echo "\nDocument delete URL - " . $spreadsheetResponseObject->getDocumentDeleteUrl() . "\n"; 120 | echo "\nDocument session delete URL - " . $spreadsheetResponseObject->getSessionDeleteUrl() . "\n"; 121 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 122 | echo "\nInvalid configuration exception." . "\n"; 123 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 124 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 125 | if ( $spreadsheetResponseObject->getKeyName() ) { 126 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 127 | } 128 | if ( $spreadsheetResponseObject->getParameterName() ) { 129 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 130 | } 131 | } else { 132 | echo "\nRequest not completed successfully\n"; 133 | } 134 | } 135 | } 136 | } catch (Exception $error) { 137 | echo "\nException while running sample code: " . $error . "\n"; 138 | } 139 | } 140 | 141 | public static function initializeSdk() { 142 | 143 | # Update the api domain based on in which data center user register your apikey 144 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 145 | $environment = new Production("https://api.office-integrator.com"); 146 | # User your apikey that you have in office integrator dashboard 147 | //Update this apikey with your own apikey signed up in office inetgrator service 148 | $authBuilder = new AuthBuilder(); 149 | $authentication = new Authentication(); 150 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 151 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 152 | $tokens = [ $authBuilder->build() ]; 153 | 154 | # Configure a proper file path to write the sdk logs 155 | $logger = (new LogBuilder()) 156 | ->level(Levels::INFO) 157 | ->filePath("./app.log") 158 | ->build(); 159 | 160 | (new InitializeBuilder()) 161 | ->environment($environment) 162 | ->tokens($tokens) 163 | ->logger($logger) 164 | ->initialize(); 165 | 166 | echo "SDK initialized successfully.\n"; 167 | } 168 | } 169 | 170 | EditSpreadsheet::execute(); 171 | 172 | -------------------------------------------------------------------------------- /spreadsheet-apis/GetSessionDetails.php: -------------------------------------------------------------------------------- 1 | setDisplayName("User 1"); 38 | 39 | $parameters->setUserInfo($userInfo); 40 | 41 | echo "\nCreating a document to demonstrate get document session information api"; 42 | 43 | $responseObject = $sdkOperations->createSheet($parameters); 44 | 45 | if ($responseObject != null) { 46 | // Get the status code from response 47 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 48 | 49 | // Get the api response object from responseObject 50 | $spreadsheetResponseObject = $responseObject->getObject(); 51 | 52 | if ($spreadsheetResponseObject != null) { 53 | // Check if the expected CreateDocumentResponse instance is received 54 | if ($spreadsheetResponseObject instanceof CreateSheetResponse) { 55 | $sessionId = $spreadsheetResponseObject->getSessionId(); 56 | 57 | $sessionsResponse = $sdkOperations->getSheetSession($sessionId); 58 | 59 | if ($sessionsResponse != null) { 60 | // Get the status code from response 61 | echo "\nStatus Code: " . $sessionsResponse->getStatusCode() . "\n"; 62 | 63 | // Get the api response object from responseObject 64 | $sessionsResponseObj = $sessionsResponse->getObject(); 65 | 66 | if ($sessionsResponseObj != null) { 67 | // Check if the expected CreateDocumentResponse instance is received 68 | if ($sessionsResponseObj instanceof SessionMeta) { 69 | echo "Session Status : " . $sessionsResponseObj->getStatus(); 70 | 71 | $sessionInfo = $sessionsResponseObj->getInfo(); 72 | 73 | if ($sessionInfo instanceof SessionInfo) { 74 | echo "\nSession Status : " . $sessionInfo->getSessionUrl(); 75 | echo "\nSession Session - Document ID : " . $sessionInfo->getDocumentId(); 76 | echo "\nSession Session URL : " . $sessionInfo->getSessionUrl(); 77 | echo "\nSession Session Delete URL : " . $sessionInfo->getSessionDeleteUrl(); 78 | echo "\nSession Session Created Time : " . $sessionInfo->getCreatedTime(); 79 | echo "\nSession Session Created Timestamp : " . $sessionInfo->getCreatedTimeMs(); 80 | echo "\nSession Session Expiry Time : " . $sessionInfo->getExpiresOn(); 81 | echo "\nSession Session Expiry Timestamp : " . $sessionInfo->getExpiresOnMs(); 82 | } 83 | $sessionUserInfo = $sessionsResponseObj->getUserInfo(); 84 | 85 | if ($sessionUserInfo instanceof SessionUserInfo) { 86 | echo "\nSession User ID : " . $sessionUserInfo->getUserId(); 87 | echo "\nSession User DisplayName : " . $sessionUserInfo->getDisplayName(); 88 | } 89 | } elseif ($sessionsResponseObj instanceof InvalidConfigurationException) { 90 | echo "\nInvalid configuration exception." . "\n"; 91 | echo "\nError Code - " . $sessionsResponseObj->getCode() . "\n"; 92 | echo "\nError Message - " . $sessionsResponseObj->getMessage() . "\n"; 93 | if ( $sessionsResponseObj->getKeyName() ) { 94 | echo "\nError Key Name - " . $sessionsResponseObj->getKeyName() . "\n"; 95 | } 96 | if ( $sessionsResponseObj->getParameterName() ) { 97 | echo "\nError Parameter Name - " . $sessionsResponseObj->getParameterName() . "\n"; 98 | } 99 | } else { 100 | echo "\nRequest not completed successfully\n"; 101 | } 102 | } 103 | } 104 | 105 | } elseif ($spreadsheetResponseObject instanceof InvalidConfigurationException) { 106 | echo "\nInvalid configuration exception." . "\n"; 107 | echo "\nError Code - " . $spreadsheetResponseObject->getCode() . "\n"; 108 | echo "\nError Message - " . $spreadsheetResponseObject->getMessage() . "\n"; 109 | if ( $spreadsheetResponseObject->getKeyName() ) { 110 | echo "\nError Key Name - " . $spreadsheetResponseObject->getKeyName() . "\n"; 111 | } 112 | if ( $spreadsheetResponseObject->getParameterName() ) { 113 | echo "\nError Parameter Name - " . $spreadsheetResponseObject->getParameterName() . "\n"; 114 | } 115 | } else { 116 | echo "\nRequest not completed successfully\n"; 117 | } 118 | } 119 | } 120 | } catch (Exception $error) { 121 | echo "\nException while running sample code: " . $error . "\n"; 122 | } 123 | } 124 | 125 | public static function initializeSdk() { 126 | 127 | # Update the api domain based on in which data center user register your apikey 128 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 129 | $environment = new Production("https://api.office-integrator.com"); 130 | # User your apikey that you have in office integrator dashboard 131 | //Update this apikey with your own apikey signed up in office inetgrator service 132 | $authBuilder = new AuthBuilder(); 133 | $authentication = new Authentication(); 134 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 135 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 136 | $tokens = [ $authBuilder->build() ]; 137 | 138 | # Configure a proper file path to write the sdk logs 139 | $logger = (new LogBuilder()) 140 | ->level(Levels::INFO) 141 | ->filePath("./app.log") 142 | ->build(); 143 | 144 | (new InitializeBuilder()) 145 | ->environment($environment) 146 | ->tokens($tokens) 147 | ->logger($logger) 148 | ->initialize(); 149 | 150 | echo "SDK initialized successfully.\n"; 151 | } 152 | } 153 | 154 | GetSessionDetails::execute(); 155 | 156 | -------------------------------------------------------------------------------- /document-apis/GetSessionDetails.php: -------------------------------------------------------------------------------- 1 | setUserId("1000"); 38 | $userInfo->setDisplayName("Prabakaran R"); 39 | 40 | $createDocumentParameters->setUserInfo($userInfo); 41 | 42 | echo "\nCreating a document to demonstrate get document session information api"; 43 | 44 | $responseObject = $sdkOperations->createDocument($createDocumentParameters); 45 | 46 | if ($responseObject != null) { 47 | // Get the status code from response 48 | echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n"; 49 | 50 | // Get the api response object from responseObject 51 | $writerResponseObject = $responseObject->getObject(); 52 | 53 | if ($writerResponseObject != null) { 54 | // Check if the expected CreateDocumentResponse instance is received 55 | if ($writerResponseObject instanceof CreateDocumentResponse) { 56 | $sessionId = $writerResponseObject->getSessionId(); 57 | 58 | echo "\nInvoking document session information api"; 59 | 60 | $sessionsResponse = $sdkOperations->getSession($sessionId); 61 | 62 | if ($sessionsResponse != null) { 63 | // Get the status code from response 64 | echo "\nStatus Code: " . $sessionsResponse->getStatusCode() . "\n"; 65 | 66 | // Get the api response object from responseObject 67 | $sessionsResponseObj = $sessionsResponse->getObject(); 68 | 69 | if ($sessionsResponseObj != null) { 70 | // Check if the expected CreateDocumentResponse instance is received 71 | if ($sessionsResponseObj instanceof SessionMeta) { 72 | echo "\nSession Status : " . $sessionsResponseObj->getStatus(); 73 | 74 | $sessionInfo = $sessionsResponseObj->getInfo(); 75 | 76 | if ($sessionInfo instanceof SessionInfo) { 77 | echo "\nSession Session - Document ID : " . $sessionInfo->getDocumentId(); 78 | echo "\nSession Session URL : " . $sessionInfo->getSessionUrl(); 79 | echo "\nSession Session Delete URL : " . $sessionInfo->getSessionDeleteUrl(); 80 | echo "\nSession Session Created Time : " . $sessionInfo->getCreatedTime(); 81 | echo "\nSession Session Created Timestamp : " . $sessionInfo->getCreatedTimeMs(); 82 | echo "\nSession Session Expiry Time : " . $sessionInfo->getExpiresOn(); 83 | echo "\nSession Session Expiry Timestamp : " . $sessionInfo->getExpiresOnMs(); 84 | } 85 | $sessionUserInfo = $sessionsResponseObj->getUserInfo(); 86 | 87 | if ($sessionUserInfo instanceof SessionUserInfo) { 88 | echo "\nSession User ID : " . $sessionUserInfo->getUserId(); 89 | echo "\nSession User DisplayName : " . $sessionUserInfo->getDisplayName(); 90 | } 91 | } elseif ($sessionsResponseObj instanceof InvalidConfigurationException) { 92 | echo "\nInvalid configuration exception." . "\n"; 93 | echo "\nError Code - " . $sessionsResponseObj->getCode() . "\n"; 94 | echo "\nError Message - " . $sessionsResponseObj->getMessage() . "\n"; 95 | if ( $sessionsResponseObj->getKeyName() ) { 96 | echo "\nError Key Name - " . $sessionsResponseObj->getKeyName() . "\n"; 97 | } 98 | if ( $sessionsResponseObj->getParameterName() ) { 99 | echo "\nError Parameter Name - " . $sessionsResponseObj->getParameterName() . "\n"; 100 | } 101 | } else { 102 | echo "\nRequest not completed successfully\n"; 103 | } 104 | } 105 | } 106 | 107 | } elseif ($writerResponseObject instanceof InvalidConfigurationException) { 108 | echo "\nInvalid configuration exception." . "\n"; 109 | echo "\nError Code - " . $writerResponseObject->getCode() . "\n"; 110 | echo "\nError Message - " . $writerResponseObject->getMessage() . "\n"; 111 | if ( $writerResponseObject->getKeyName() ) { 112 | echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n"; 113 | } 114 | if ( $writerResponseObject->getParameterName() ) { 115 | echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n"; 116 | } 117 | } else { 118 | echo "\nRequest not completed successfully\n"; 119 | } 120 | } 121 | } 122 | } catch (Exception $error) { 123 | echo "\nException while running sample code: " . $error . "\n"; 124 | } 125 | } 126 | 127 | public static function initializeSdk() { 128 | 129 | # Update the api domain based on in which data center user register your apikey 130 | # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html 131 | $environment = new Production("https://api.office-integrator.com"); 132 | # User your apikey that you have in office integrator dashboard 133 | //Update this apikey with your own apikey signed up in office inetgrator service 134 | $authBuilder = new AuthBuilder(); 135 | $authentication = new Authentication(); 136 | $authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480"); 137 | $authBuilder->authenticationSchema($authentication->getTokenFlow()); 138 | $tokens = [ $authBuilder->build() ]; 139 | 140 | # Configure a proper file path to write the sdk logs 141 | $logger = (new LogBuilder()) 142 | ->level(Levels::INFO) 143 | ->filePath("./app.log") 144 | ->build(); 145 | 146 | (new InitializeBuilder()) 147 | ->environment($environment) 148 | ->tokens($tokens) 149 | ->logger($logger) 150 | ->initialize(); 151 | 152 | echo "SDK initialized successfully.\n"; 153 | } 154 | } 155 | 156 | GetSessionDetails::execute(); 157 | 158 | --------------------------------------------------------------------------------