PHP SDK Errors and Solutions

Error while fetching access token from refresh token

Reason

The configuration details are not given in configuration.properties and oauth_configuration.properties files.

Solution

Set configuration and OAuth configuration properties as displayed in the below image.

Error while fetching access token from grant token

Reason

The grant token has expired.

Solution

Regenerate grant token and use within the stipulated time.

Undefined index: Email

Reason

The user has not included the scope “Aaaserver.profile.Read” while generating the grant token(authorization code).

Solution

Include the scope “Aaaserver.profile.Read” while generating the grant token(authorization code).

Undefined offset 1

Reason

SSL certificate is not updated.

Solution 1

Download the file from https://curl.haxx.se/ca/cacert.pem and add this line to the php.ini file.
curl.cainfo=“path/to/file/cacert.pem”

Solution 2

Add the below line before $result=curl_exec($curl_pointer) in the firerequest() and downloadFile() methods of ZohoHTTPConnector.php file, and the post() and get() methods of the ZohoOAuthHTTConnector.php file.
curl_setopt($curl_pointer, CURLOPT_SSL_VERIFYPEER, 0);

This solution will bypass the verification of the SSL certificate. Solution 1 is recommended.

Refresh token is not provided

Reason

The user tries to call an API without generating access and refresh tokens.

Solution

Generate access and refresh tokens from grant token.

1. Current user should be either set in ZCRMRestClient or in configuration.properties file

Reason

The email ID of the current user is not specified in configuration map or configuration.properties file.

Solution

Enter the email ID of the current user in the configuration.properties file or on the server as shown below.

2. Current user should be either set in ZCRMRestClient or in configuration.properties file

Reason

The SDK is not initialized by not calling ZCRMRestClient::initialize().

Solution

Follow the steps mentioned in Initialization - PHP SDK to initialize the SDK.

Exception while fetching access token from grant token

Reason

The user tries to generate grant token and access token from different domains. For example, the user generates the grant token from accounts.zoho.com and tries to generate the access token from accounts.zoho.eu.

Solution

Generate both grant token and access token from the same domain.

Invalid OAuth Token

Reason

The user generates access token in a domain but tries to access a record in a different domain. For example, the user generates the access token from www.zohoapis.com and tries to access a module in www.zohoapis.eu

Solution

Access the records in the same domain as you generated the access token in, that is, specify the same domain name suffix in accounts_url and apiBaseUrl.

Undefined offset

Reason

The base url for API is not set in "apiBaseUrl" in the configuration.properties file.

Solution

Specify the base URL in "apiBaseUrl" in the configuration.properties file.

Class 'ZCRMRestClient' not found

Reason

The vendor path is not included in the PHP file.

Solution

Add the vendor path require ‘vendor/autoload.php’ in the PHP file.

Call to undefined method APIResponse::getId()

Reason

Passing an incorrect object to the method setOwner()

Solution

Use the method getData() to get the ZCRM user instance before passing the object to the method setOwner().

ZCRMException Caused by:'Unknown ZCRMException'

Reason

The apiBaseUrl key in the configuration dictionary must have had the value as "https://www.zohoapis.com/". The slash at the end of the line is automatically added by the SDK. Hence if the user adds a slash as well, the final input to the SDK will have two slashes. Ex: "https://www.zohoapis.com//".

Solution

Remove the (/) slash after https://www.zohoapis.com in the "apiBaseUrl" key of the confirguration dictionary.

ZohoOAuthException Caused by:'ZohoOAuthException Caused by:'Exception while fetching access token from refresh token - HTTP/1.1 404

Reason

The accounts_url key in the configuration dictionary must have had the value as "https://accounts.zoho.com/". The slash at the end of the line is automatically added added by the SDK. Hence if the user adds a slash as well, the final input to the SDK will have two slashes. Ex: "https://accounts.zoho.com//".

Solution

Remove the (/) slash after https://accounts.zoho.com in the "accounts_url" key of the configuration dictionary.

ZCRMException Caused by:'Unknown ZCRMException'

Reason

The "apiVersion" key in the configuration dictionary is "V2", with a capital "V".

Solution

Change the value of apiVersion to "v2" in the configuration dictionary.