Telephone: +44 7973 504232



 

Zoho CRM API PHP SDK

Zoho provide a PHP SDK to interface with their CRM via an API.  This should be a useful resource to read and write data from and to the CRM.  It uses oAuth2 for authentication.  Getting this working has been a difficult and time-consuming operation.  Looking at the community pages, it seems I have not been the only one to struggle with this, so I thought I would provide some pointers.

Generally the more technical Zoho CRM documentation is poor. There is lots of historic  stuff, some of which is out of date.  There are broken links.  There is lots of repetition which tells you the same thing, without ever quite covering the missing elements you are after.

A reasonable starting point is the README.md text file in the vendor/zohocrm/php-sdk folder of the standard php sdk installation.  Read this first, but then read Cindy Cullen’s blog at:

https://cullenwebservices.com/using-zohos-crm-version-2-php-sdk-api-with-oauth/

Which is clear, even if, having got it working, she subsequently abandons using the API.

If things error out, see:

https://www.zoho.com/crm/developer/docs/php-sdk/errors-solutions.html



Which took me some time to find, but was invaluable in fixing a couple of show-stoppers.

Some points to note:

Domains

If, like me,  you are accessing the European servers and have used those to get your grant token, then set
accounts_url=
https://accounts.zoho.eu in the oauth_configuration.properties file AND
apiBaseUrl=www.zohoapis.eu in configuration.properties.

Redirect

I spent ages looking through the provided sdk for a callback function to put in the redirect_uri, and even quizzed the support team as to where such a file could be found.  It finally dawned on me that this uri could be any of your php files that call ZCRMRestClient::initialize(), as this will handle the call-back.  Just ensure the registered uri and the one in your configuration files are the same.



Furthermore, as the call-back is actually handled by the browser, this uri can be on your own machine via the localhost domain, so you don’t need to deploy code to a web server for development and initial testing.  

 

Paths

The README.md files says the path to the log file needs to be an absolute path.  You may be relieved to know that this is not correct.

I hope this helps you get the API working with minimal fuss.

John Davis

5 July 2019