1. Go to this page and download the library: Download tristanjahier/zoho-crm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tristanjahier / zoho-crm example snippets
// Create an API client
$client = new Zoho\Crm\V2\Client(
new Zoho\Crm\V2\AccessTokenBroker('MY_API_CLIENT_ID', 'MY_API_CLIENT_SECRET', 'MY_API_REFRESH_TOKEN')
);
// Create a request and execute it
$response = $client->newRawRequest('Calls')->param('page', 2)->execute();
// Retrieve all deals modified for the last time after April 1st, 2019
$deals = $client->records->deals->all()->modifiedAfter('2019-04-01')->get();
// Retrieve records by ID
$myLead = $client->records->leads->find('1212717324723478324');
$myProduct = $client->records->products->find('8734873457834574028');
// Create a new contact
$result = $client->records->contacts->insert([
'First_Name' => 'Jean',
'Last_Name' => 'Dupont',
'Email' => '[email protected]'
]);
$contactId = $result['details']['id'];
// Update the name of the contact
$client->records->contacts->update($contactId, ['First_Name' => 'Jacques']);
// Delete this contact
$client->records->contacts->delete($contactId);
$tokenBroker = new Zoho\Crm\V2\AccessTokenBroker('MY_API_CLIENT_ID', 'MY_API_CLIENT_SECRET', 'MY_API_REFRESH_TOKEN');
$client = new Zoho\Crm\V2\Client($tokenBroker);
$tokenStore = new Zoho\Crm\AccessTokenStorage\FileStore('dev/.token.json');
$client = new Zoho\Crm\V2\Client($tokenBroker, $tokenStore);
if (! $client->accessTokenIsValid()) {
$client->refreshAccessToken();
}
// Retrieve the second page of records from the Contacts module, modified after April 1st, 2019:
$request = $client->newRawRequest()
->setHttpMethod('GET')
->setUrl('Contacts')
->setHeader('If-Modified-Since', '2019-04-01')
->setUrlParameter('page', 2);
// Retrieve a Deals record whose ID is 9032776450912388478:
$request = $client->newRawRequest('Deals/9032776450912388478');
$client->records->calls->newListRequest()->autoPaginated()->concurrency(5)->get();
// or
$client->records->calls->all()->concurrency(5)->get();
// Returns a single entity of type Zoho\Crm\V2\Records\Record:
$client->records->calls->find('<record ID>');
// Returns a collection of entities (Zoho\Crm\V2\Users\User):
$client->users->all()->get();
// If $records is an instance of Zoho\Crm\Entities\Collection...
// You can access items with square brackets:
$aRecord = $records[2];
$records[] = new Zoho\Crm\V2\Records\Record(['Phone' => '+1234567890']);
// And you can loop through it:
foreach ($records as $record) {
...
}