Mac/Linux | curl -sS https://getcomposer.org/installer | php (terminal command) |
Windows | https://getcomposer.org/doc/00-intro.md#installation-windows |
composer require zohocrm/php-sdk-4.0 (for v4 APIs) composer require zohocrm/php-sdk-5.0 (for v5 APIs) |
require 'vendor/autoload.php'; |
Methods | Description |
findToken(Token $token) | Invoked before firing a request to fetch the saved tokens. This method returns an implementation of Token interface object for the library to process it. |
saveToken(Token $token) | Invoked after fetching access and refresh tokens from Zoho. This method saves the token details. |
deleteToken($id) | This method is used to delete the given token details. |
getTokens() | The method is used to retrieve all the stored tokens. |
deleteTokens() | The method to delete all the stored tokens. |
findTokenById($id) | This method is used to retrieve the user token details based on the unique ID. |
CREATE DATABASE zoho; // use this to create database named zoho // use this to create a table named token, with the following necessary columns CREATE TABLE token ( id varchar(10) NOT NULL, user_name varchar(255) NOT NULL, client_id varchar(255), client_secret varchar(255), refresh_token varchar(255), access_token varchar(255), grant_token varchar(255), expiry_time varchar(20), redirect_url varchar(255), primary key (id) ); |
$token = (new OAuthBuilder()) ->clientId("clientId") ->clientSecret("clientSecret") ->userSignature($user) //optional ->grantToken("grantToken") ->redirectURL("redirectURL") //optional ->build(); |
$token = (new OAuthBuilder()) ->clientId("clientId") ->clientSecret("clientSecret") ->userSignature($user) //optional ->refreshToken("refreshToken") ->build(); |
$token = (new OAuthBuilder()) ->userSignature($user) //optional ->accessToken("accessToken") ->build(); |
$token = (new OAuthBuilder()) ->id("id") ->build(); |
$logger = (new LogBuilder()) ->level(Levels::INFO) ->filePath("/Documents/php_sdk_log.log") ->build(); |
Configuration Key | Description |
autoRefreshFields Default Value : False | A boolean configuration key to enable or disable automatic refreshing of module fields in the background. If set to true, fields are refreshed every hour, and if set to false, fields must be manually refreshed or deleted. |
pickListValidation Default Value : True | This field enables or disables pick list validation. If enabled, user input for pick list fields is validated, and if the value does not exist in the pick list, the SDK throws an error. If disabled, the input is not validated and the API call is made. |
enableSSLVerification Default Value : True | A boolean field to enable or disable curl certificate verification. If set to true, the SDK verifies the authenticity of certificate. If set to false, the SDK skips the verification. |
connectionTimeout Default Value : 0 | The maximum time (in seconds) to wait while trying to connect. Use 0 to wait indefinitely. |
timeout Default Value : 0 | The maximum time (in seconds) to allow cURL functions to execute. Use 0 to wait indefinitely. |
$requestProxy = (new ProxyBuilder()) ->host("proxyHost") ->port("proxyPort") ->user("proxyUser") ->password("password") ->build(); |
<?php use com\zoho\api\authenticator\OAuthBuilder; use com\zoho\api\authenticator\store\DBBuilder; use com\zoho\crm\api\InitializeBuilder; use com\zoho\crm\api\UserSignature; use com\zoho\crm\api\dc\USDataCenter; use com\zoho\api\logger\LogBuilder; use com\zoho\api\logger\Levels; use com\zoho\crm\api\SDKConfigBuilder; use com\zoho\crm\api\ProxyBuilder; require_once "vendor/autoload.php"; class Initialize { public static function initializeSDK() { $user = new UserSignature("patricia@zoho.com"); $environment = USDataCenter::PRODUCTION(); $token = (new OAuthBuilder()) ->clientId("1000.xxxxxxxxxxxxxxxx") ->clientSecret("554a9xxxxxxxxxxxxxxxxx") ->userSignature($user) //optional ->refreshToken("1000.xxxxxxxxxxxxxxxxxxxx") ->redirectURL("www.zoho.com") //optional ->build(); $logger = (new LogBuilder()) ->level(Levels::INFO) ->filePath("/Documents/php_sdk_log.log") ->build(); $tokenstore = (new DBBuilder()) ->host("insert_your_hostname_here") ->databaseName("insert_your_database_name_here") ->userName("insert_your_db_username_here") ->password("insert_your_db_password_here") ->portNumber("insert_your_portnumber_here") ->tableName("insert_your_table_name_here") ->build(); $autoRefreshFields = false; $pickListValidation = false; $connectionTimeout = 2; $timeout = 2; $enableSSLVerification = false; $configInstance = (new SDKConfigBuilder()) ->autoRefreshFields($autoRefreshFields) ->pickListValidation($pickListValidation) ->sslVerification($enableSSLVerification) ->connectionTimeout($connectionTimeout) ->timeout($timeout) ->build(); $resourcePath = "/Documents/phpsdk-application"; $requestProxy = (new ProxyBuilder()) ->host("proxyHost") ->port("proxyPort") ->user("proxyUser") ->password("password") ->build(); (new InitializeBuilder()) ->environment($environment) ->token($token) ->store($tokenstore) //optional ->SDKConfig($configInstance) //optional ->resourcePath($resourcePath) //optional ->logger($logger) //optional ->requestProxy($requestProxy) //optional ->initialize(); } } Initialize::initializeSDK(); ?> |
Writer is a powerful online word processor, designed for collaborative work.