PHP SDK - 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 services of Zoho CRM.
A point to note would be that the developer of the client application should create programming code elements along with interface implementations, instances or objects. Authentication to access Zoho CRM APIs is through OAuth2.0 authentication mechanism. Invariably, HTTP requests and responses are taken care of by the SDK.
A sample of how an SDK acts a middle ware or interface between Zoho CRM and a client PHP application.
- For the sake of better explanation, we have used Eclipse to describe how to get started on using the SDK.
If you are facing SSL related issues, make sure your SSL certificate is valid and configured properly. You can download the certificate bundle from here. To add the SSL certificate, locate the php.ini file in the PHP folder in your system, and add these lines to your certificate.
PHP SDK allows you to
- Exchange data between Zoho CRM and the client application where the CRM entities are modeled as classes.
- Declare and define CRM API equivalents as simple functions in your PHP application.
- Push data into Zoho CRM by accessing appropriate APIs of the CRM Service.
PHP SDK is installable through the composer. A composer is a tool for dependency management in PHP. SDK expects the following from the client app
- Client app must have PHP(version 7 and above) or above with curl extension enabled.
- PHP SDK must be installed into client app though composer.
Including the SDK in your project
You can include the SDK to your project using:
- 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:
To install composer on windows machine:
- Install PHP SDK Here's how you install the SDK
- Navigate to the workspace of your client app.
Run the command below:
composer require zohocrm/php-sdk-2.0:4.0.0
- The PHP SDK will be installed and a package named vendor will be created in the workspace of your client app.
Using the SDK
Add the below line in PHP files of your client app , where you would like to make use of PHP SDK.
Through this line, you can access all the functionalities of the PHP SDK. The namespaces of the class to be used must be included within the "use" statement.
- It is mandatory for the client to have ZohoCRM.settings.fields.ALL to access all the record operations API. Otherwise, the system returns the OAUTH-SCOPE-MISMATCH error
- The access and refresh tokens are environment-specific and domain-specific. When you handle various environments and domains such as Production, Sandbox, or Developer and IN, CN, US, EU, or AU, respectively, you must use the access token and refresh token generated only in those respective environments and domains. The SDK throws an error, otherwise.
For example, if you generate the tokens for your Sandbox environment in the CN domain, you must use only those tokens for that domain and environment. You cannot use the tokens generated for a different environment or a domain.