Get All Record In CRM Module Using SDK In PHP

Here we learn how to Get All record with ZOHO REST API using SDK in PHP.

To integrate ZOHO API Using SDK follow below step,

1) You need to create a ZOHO Application. If you have not created then please create it by using the below link:

2) We need to include the vendor/autoload.php file. so first we need to install PHP SDK using composer.

  • Run the below command for install composer

    To install composer on mac/ Linux system use below link:

    To install composer on Windows system use below link:
  • Install PHP SDK
    1) Give the path of your client app(In which you want to add vendor folder).
    2) Run the command below:
    composer require zohocrm/php-sdk


  • The PHP SDK will be installed and a package named vendor would be created in the workspace of your client app.

3) Now we need to generate a refresh code for security purposes. so  follow steps of the below URL,

4) Create config.php file and add config file below code

<?php return array ( 
       'userIdentifier'         => '', 
       'client_id'              => 'put client_register_id', 
       'client_secret'          => 'put client_register_secrete_key', 
       'redirect_uri'           => '', 
       'token_persistence_path' => 'zcrm_oauthtokens.txt', 
       'scope'                  => 'ZohoCRM.modules.ALL', 
       'refresh_code'           => 'your refresh code'

client_id, client_secret, and redirect_uri that you get after registering your Zoho application.
token_persistence_path is a path for token storage;
The scope is to Choose what data can be accessed by your application.
refresh code is code that is getting from the access token.

5) Create get-record.php file and add below code in this file

use zcrmsdk\crm\crud\ZCRMInventoryLineItem;
use zcrmsdk\crm\crud\ZCRMRecord;
use zcrmsdk\crm\crud\ZCRMTax;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
$configs = include("config.php");
$client_id     = $configs['client_id'];
$client_secret = $configs['client_secret'];
$redirect_uri  = $configs['redirect_uri'];
$identifier    = $configs['userIdentifier'];
$token_persistence_path = $configs['token_persistence_path'];
class Get_contacts{
    public function __construct()
        global $client_id, $client_secret, $redirect_uri, $identifier, $token_persistence_path; 
        $configuration = array(
              "client_id"              => $client_id,
              "client_secret"          => $client_secret,
              "redirect_uri"           => $redirect_uri,
              "currentUserEmail"       => $identifier,
              "token_persistence_path" => $token_persistence_path
    public function getRecords()
        $moduleGet       = ZCRMRestClient::getInstance()->getModuleInstance("{module_name}"); // to get the instance of the module
	$moduleGetRecord = $moduleGet->getRecords( "Field_name_to_sort_by" , "sort_order", "$page = 1, $perPage = 20 ); // get all record from given module
	$recordsArray    = $moduleGetRecord->getData(); // get all data from record
$obj = new Get_records();

: The API name of the module
Possible_Module_name: leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, and notes.
Field_name_to_sort_by : To get list of all records specific field wise. e.g : Last_Name, Email
:  To get List in Ascending or Descending Order
page : 1,2,3,4
per_page : How many record want to display per page

Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories