Configuration - PHP SDK

Configuration - PHP SDK

Before you get started with creating your php application, you need to first authenticate the app with Zoho. And to do that there are some configuration procedures that need to be in place. There are two methods in which you can authenticate your application:
  • Passing a configuration array - and then call ZCRMRestClient::initialize($configuration);
    • The array option is available only for version 1.1.0 and above.
  • Using properties files in resources folder- and then call ZCRMRestClient::initialize();

Properties file

Your OAuth Client details should be given to the PHP SDK as a property file. In PHP SDK, we have placed a configuration file (oauth_configuration.properties). Please place the respective values in that file. You can find that file under ‘vendor/zohocrm/php-sdk/src/resources’.

Based on your domain(EU,CN) please change the value of 'accounts_url'. Default value set as US domain. Please fill only the following keys.
  1. client_id=
  2. client_secret=
  3. redirect_uri=
  4. accounts_url=https://accounts.zoho.com/
  5. token_persistence_path=
Only the keys displayed above are to be filled.
  • client_id, client_secret and redirect_uri are your OAuth client’s configurations that you get after registering your Zoho client.
  • access_type must be set to offline only because online OAuth client is not supported by the PHP SDK as of now.
  • persistence_handler_class is the implementation of the ZohoOAuthPersistenceInterface i.e. ZohoOAuthPersistenceHandler.
  • token_persistence_path is the path to store the OAuth related tokens in file. If this is set, no need of database for persistence.
Create a file named "ZCRMClientLibrary.log" in your client app machine and mention the absolute path of the created file in configuration.properties for the key “applicationLogFilePath”. You can find that file under 'vendor/zohocrm/php-sdk/src/resources'. This file is to log the exceptions occurred during the usage of PHP SDK.

Please fill only the following key
  1. applicationLogFilePath=
To make API calls to sandbox account, please change the value of following key to true in configurations.properties file. By default the value is false.
  1. sandbox=true
If your application needs only a single user authentication then you have to set the user EmailId in configurations.properties file as given below:
  1. currentUserEmail=user@email.com
In order to work with multi user authentication, you need to set the user EmailId in PHP super global variable ‘$_SERVER’ as given below:
  1. $_SERVER[‘user_email_id’]=“user@email.com
You can use $_SERVER variable for single user authentication as well, but it is recommended to go with setting up of email Id in configuration.properties file.

If you do not set the user email as a super global variable, then SDK expects it from configuration.properties file. If user email is not set in any of these two then PHP SDK will throw exception.

Configuration Array

You can now pass the configuration values as php array(key-value pair) as argument when you call the ZCRMRestclient::initialize() function. Below is the list of keys that are to be in the array.

Mandatory Keys
Optional Keys
client_id
applicationLogFilePath
client_secret
sandbox
redirect_uri
apiBaseUrl
currentUserEmail
apiVersion
client_secret
access_type
 
accounts_url
 
persistence_handler_class
 
token_persistence_path

Note
  • The key "currentUserEmail" must be specified if not present globally(existing functionality).
  • If the Optional keys are not specified, their default values will be assigned automatically.
  • The 'apiBaseUrl' and 'accounts_url' are mandatory in case the user is not in the "com" domain.

Below is an example of a PHP array containing the mandatory keys.
  1. $configuration = array("client_id"=>"value","client_secret"=>"value","redirect_uri"=>"value","currentUserEmail"=>"value");
Below is an example of a PHP array containing all the keys.
  1. $configuration=array("client_id"=>"value","client_secret"=>"value","redirect_uri"=>"value","currentUserEmail"=>"value","applicationLogFilePath"=>"value", "sandbox"=>"value","apiBaseUrl"=>"value","apiVersion"=>"value",access_type"=>"value","accounts_url"=>"value","persistence_handler_class"=>"value","token_persistence_path"=>"value");

    • Related Articles

    • PHP SDK - An Overview

      PHP SDK offers a way to create client PHP applications that can be integrated with Zoho CRM. This SDK makes the access and use of necessary CRM APIs with ease. In other words, it serves as a wrapper for the REST APIs, making it easier to use the ...
    • Initialization - PHP SDK

      The app would be ready to be initialized after defining the OAuth configuration file. Generating self-authorized grant and refresh token For self client apps, the self authorized grant token should be generated from the Zoho Developer Console ...
    • Installation - PHP SDK

      Install Composer(if not installed) Run this command to install the composer curl -sS https://getcomposer.org/installer | php To install composer on mac/ linux machine: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx To install ...
    • Configuration - C# SDK

      Before you get started with creating your C# application, you need to first authenticate the app with Zoho. And to do that there are some configuration procedures that need to be in place. Basically, the OAuth Client details must be given as a ...
    • Configuration - Java SDK

      Setting up the configuration is a system engineering process, for establishing and maintaining the consistency of the application's performance, functional and physical attributes with its requirements, design and operational information throughout ...