PHP code example of officeintegrator / zoi-php-sdk
1. Go to this page and download the library: Download officeintegrator/zoi-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
officeintegrator / zoi-php-sdk example snippets
/*
* Refer this help page for api end point domain details - https://www.zoho.com/officeintegrator/api/v1/getting-started.html
*/
$environment = new Production("https://api.office-integrator.com");
/**
* You can configure where the apikey needs to added in the request object.
* User can either pass the apikey in the addParam or addHeader method
*/
$authBuilder = new AuthBuilder();
$authentication = new Authentication();
$authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480");
$authBuilder->authenticationSchema($authentication->getTokenFlow());
$tokens = [ $authBuilder->build() ];
$apikey = new APIKey("2ae438cf864488657cc9754a27daa480", Constants::PARAMS);
/*
* Create an instance of Logger Class that d. Can be configured by typing Levels "." and choose any level from the list displayed.
* filePath -> Absolute file path, where messages need to be logged.
*/
$logger = (new LogBuilder())
->level(Levels::INFO)
->filePath("./app.log")
->build();
use com\zoho\api\authenticator\AuthBuilder;
use com\zoho\officeintegrator\dc\apiserver\Production;
use com\zoho\officeintegrator\InitializeBuilder;
use com\zoho\officeintegrator\logger\Levels;
use com\zoho\officeintegrator\logger\LogBuilder;
use com\zoho\officeintegrator\v1\Authentication;
fice-integrator.com");
# User your apikey that you have in office integrator dashboard
//Update this apikey with your own apikey signed up in office inetgrator service
$authBuilder = new AuthBuilder();
$authentication = new Authentication();
$authBuilder->addParam("apikey", "2ae438cf864488657cc9754a27daa480");
$authBuilder->authenticationSchema($authentication->getTokenFlow());
$tokens = [ $authBuilder->build() ];
# Configure a proper file path to write the sdk logs
$logger = (new LogBuilder())
->level(Levels::INFO)
->filePath("./app.log")
->build();
(new InitializeBuilder())
->environment($environment)
->tokens($tokens)
->logger($logger)
->initialize();
echo "SDK initialized successfully.\n";
}
}
Initialize::initializeSdk();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.