zoho-php
PHP wrapper for Zoho with Laravel 5.* support, (*1)
PACKAGE UNDER DEVELOPMENT, NOT ALL METHODS DOCUMENTED, (*2)
Installation
To install this package you must modify your composer.json file and run composer update, (*3)
"require": {
"mjmarianetti/zoho": "dev-master"
}
Or you can run the composer require mjmarianetti/zoho-php, (*4)
Laravel
Open config/app.php and register the required service provider, (*5)
'providers' => [
...
Mjmarianetti\Zoho\ZohoServiceProvider::class
]
Then you should publish the config file, (*6)
php artisan vendor:publish --provider="Mjmarianetti\Zoho\ZohoServiceProvider"
Configuration
You can configure the options provided in you .env file., (*7)
ZOHO_SCOPE=crmapi
ZOHO_AUTHTOKEN=<INSERT-YOUR-TOKEN-HERE>
ZOHO_FORMAT=json
The default options are:, (*8)
ZOHO_SCOPE=crmapi
ZOHO_FORMAT=json
Usage
Initialization
Include the ZohoClient in your project/file, (*9)
use Mjmarianetti\Zoho\ZohoClient;
If you are using Laravel you can inject it as a dependency, (*10)
public function test(ZohoClient $client)
{
Or if you are using it as a stand-alone library or with another framework, you have to provide a default configuration like:, (*11)
$config = [
'authtoken' => 'YOUR-TOKEN',
'scope' => 'crmapi',
'format' => 'json', // or xml
'baseurl' => 'https://crm.zoho.com/crm/private/'
];
$client = new ZohoClient($config);
Methods
After initialization you can call the API., (*12)
All this methods follow the same pattern, where $resource is the Module you want to call, and $params all the parameters that you want to use., (*13)
The response returned usually follows the pattern:, (*14)
$result = $client->getRecords(RESOURCE,$params);
$result->response->nodata;
$result->response->result->FL
$result->response->result->RESOURCE->row
Available $resource values
API format --> https://www.zoho.com/crm/help/api/modules-fields.html, (*15)
getRecords
https://www.zoho.com/crm/help/api/getrecords.html, (*16)
$client->getRecords($resource, $params = [])
getRecordsById
https://www.zoho.com/crm/help/api/getrecordbyid.html, (*17)
$params should contain either id or idlist value., (*18)
$client->getRecordsById($resource, $params = [])
Note: idlist should be a unique set of Ids separated by semicolon, up to 100 values, (*19)
getMyRecords
https://www.zoho.com/crm/help/api/getmyrecords.html, (*20)
$client->getMyRecords($resource, $params = [])
getDeletedRecordIds
https://www.zoho.com/crm/help/api/getdeletedrecordids.html, (*21)
$client->getDeletedRecordIds($resource, $params = [])
//response->result->DeletedIDs;
getSearchRecordsByPDC
https://www.zoho.com/crm/help/api/getsearchrecordsbypdc.html, (*22)
$client->getSearchRecordsByPDC($resource, $params = [])
deleteRecords
https://www.zoho.com/crm/help/api/deleterecords.html, (*23)
$client->deleteRecords($resource, $params = [])
https://www.zoho.com/crm/help/api/getrelatedrecords.html, (*24)
$client->getRelatedRecords($resource, $params = [])
getFields
https://www.zoho.com/crm/help/api/getfields.html, (*25)
$client->getFields($resource, $params = [])
getUsers
https://www.zoho.com/crm/help/api/getusers.html, (*26)
$client->getUsers($resource, $params = [])
delink
https://www.zoho.com/crm/help/api/delink.html, (*27)
$client->delink($resource, $params = [])
downloadFile
https://www.zoho.com/crm/help/api/downloadfile.html, (*28)
$client->downloadFile($resource, $params = [])
deleteFile
https://www.zoho.com/crm/help/api/deletefile.html, (*29)
$client->deleteFile($resource, $params = [])
downloadPhoto
https://www.zoho.com/crm/help/api/downloadphoto.html, (*30)
$client->downloadPhoto($resource, $params = [])
deletePhoto
https://www.zoho.com/crm/help/api/deletephoto.html, (*31)
$client->deletePhoto($resource, $params = [])
getModules
https://www.zoho.com/crm/help/api/getmodules.html, (*32)
$client->getModules($resource, $params = [])
searchRecords
https://www.zoho.com/crm/help/api/searchrecords.html, (*33)
$client->searchRecords($resource, $params = [])
Iterator
If you would like to use a iterator to loop through the data received, you can use it like this:, (*34)
use Mjmarianetti\Zoho\Helpers\ZohoResponseIterator;
use Mjmarianetti\Zoho\ZohoClient;
...
$response = $zc->getRecords('Accounts', []);
$it = new ZohoResponseIterator((array) $response->response->result->Accounts->row);
foreach ($it as $key => $value) {
//$value->val and $value->content;
}
For now, you should check that $response->response->result->Resource->row is not null, (*35)