This is an API wrapper library for Zoho CRM, written in PHP.
It aims to cover the whole API (every module and method), while providing a great abstraction and very easy-to-use methods.
- PHP :
5.5+
- PHP cURL extension enabled
This package is currently at an early development stage. Full documentation will come when it is stable enough.
// Create a Zoho client
$zoho = new Zoho\CRM\Client('MY_ZOHO_AUTH_TOKEN');
// Use its supported modules to make easy requests...
$one_lead = $zoho->leads->getById('1212717324723478324');
$many_leads = $zoho->leads->getByIds(['8734873457834574028', '3274736297894375750']);
$admins = $zoho->users->getAdmins();
// ...or build them manually
$response = $zoho->request('Module', 'method', ['a_parameter' => 'blablebloblu']);
[Source] https://www.zoho.com/crm/help/api/using-authentication-token.html#Generate_Auth_Token
- Connect to https://accounts.zoho.com
- Send request to
https://accounts.zoho.com/apiauthtoken/nb/create?SCOPE=ZohoCRM/crmapi&EMAIL_ID=[Username/EmailID]&PASSWORD=[Password]&DISPLAY_NAME=[ApplicationName]
- Expected response
#
#Mon Apr 23 07:36:42 PDT 2018
AUTHTOKEN=8c40d6720636c6bb2eadace2d2243ed1
RESULT=TRUE
Methods | Comments | Response |
---|---|---|
fetch | execute query for the next page available | Response Object |
fetchAll | execute queries for all pages available | Array of Response |
getResponses | all responses fetched | Array of Response |
getNumberOfPagesFetched | amount of pages fetched | Integer |
Methods | Comments | Response |
---|---|---|
getContent | get JSON parsed response | Object |
getRawData | get raw response | Object |
By default, some modules are enabled in src/Client.php
- Info
- Users
- Leads
- Potentials
- Calls
- Contacts
- Products
Every modules (except Users) have the following methods (src/Api/Modules/AbstractRecordsModule.php
):
- getAll
- getById
- getMine
- search
- getBy
- getRelatedById
- exists
- insert
- insertMany
- update
- updateMany
- delete
- deleteMany
- getDeletedIds
- Method:
getAll
- Data Params
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
/**
* @var $many_leads \Zoho\CRM\Api\RequestPaginator
*/
$leads = $zoho->leads->getAll();
echo '<pre>';
print_r($leads->fetch()->getContent());
echo '</pre>';
- Response
RequestPaginator Object
- Method:
getById
- Data Params Record ID
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$lead = $zoho->leads->getById('3211639000000152457');
echo '<pre>';
print_r($lead->getContent());
echo '</pre>';
- Response
Response Object
- Method:
insert
- Data Params Array
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$zoho->leads->insert([
'Company' => 'TEST',
'Last Name' => 'TEST'
]);
- Response
Response Object
- Method:
delete
- Data Params Record ID
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$zoho->leads->delete('3211639000000152457');
- Response
Response Object
- Method:
deleteMany
- Data Params Array
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$leads = $zoho->leads->deleteMany(['3211639000000152553', '3211639000000152560']);
echo '<pre>';
print_r($leads);
echo '</pre>';
- Response
Response Object
{"result":{"code":"5000","message":"Record Id(s) : 3211639000000152553;3211639000000152560,Record(s) deleted successfully"}
- Method:
search
- Data Params String
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$leads = $zoho->leads->search('((Company:TEST)OR(Last Name:TEST))');
echo '<pre>';
print_r($leads->fetch()->getContent());
echo '</pre>';
- Response
RequestPaginator Object
- Method:
getBy
- Data Params String, String
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$leads = $zoho->leads->getBy('Company', 'TEST');
echo '<pre>';
print_r($leads->fetch()->getContent());
echo '</pre>';
- Response
RequestPaginator Object
- Method:
update
- Data Params ID, Data
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$lead = $zoho->leads->update('3211639000000155006', [
'Company' => 'TEST99'
]);
echo '<pre>';
print_r($lead->getContent());
echo '</pre>';
- Response
Response Object
- Method:
updateMany
- Data Params Data
- Code sample
require './vendor/autoload.php';
// Create a Zoho client
$zoho = new Zoho\CRM\Client('0c85ee5db4119df7ad21bb9581d08670');
$leads = $zoho->leads->updateMany([
[
'Id' => '3211639000000158001',
'Company' => 'Company modified'
],
[
'Id' => '3211639000000155013',
'Company' => 'Company modified 2'
]
]);
echo '<pre>';
print_r($leads->getRawData());
echo '</pre>';
- Response
Response Object
- Set AUTH_TOKEN in
phpunit.xml
- Run by executing
./vendor/bin/phpunit
command