Searching Record In CRM Module Using SDK PHP

Here we learn how to Search records with ZOHO REST API using SDK in PHP.

To integrate ZOHO API Using SDK follow the below steps,

1) You need to create a ZOHO Application. If you have not created then please create 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 to install composer
    To install composer on mac/ Linux system use the below link:

    To install composer on Windows system use the 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 as given below:
    composer require zohocrm/php-sdk
  • The PHP SDK will be installed in your application and a package named vendor would be created.

3) A refresh token is required to use ZOHO REST API. Refer to the below URL to generate a refresh token.

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

return array (
  'userIdentifier'	   => '',
  'client_id'		   => 'client_id',
  'client_secret'    	   => 'client secret Key',
  'redirect_uri'	   => '',
  'token_persistence_path' => 'zcrm_oauthtokens.txt',
  'scope'		   => 'ZohoCRM.modules.ALL',
  'refresh_code'	   => 'refresh code', // which is get from postman

client_id: This is getting from your Zoho app or Zoho account.
This is getting from your Zoho app or Zoho account.
redirect_uri:  This Callback URL that you registered during the Zoho app registration.
token_persistence_path: is the path for token storage;
Scope:  Choose what data can be accessed by your application.
refresh code: Code which is getting from the access token.

5) Create a search-record.php file and add the below code,

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 Search_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 search_record() {
        $moduleSearch = ZCRMRestClient::getInstance()->getModuleInstance("module_name");
        $response = $moduleSearch->searchRecordsByCriteria("("( ( Last_Name:starts_with:g ) and ( ) )" )",1,200 );  //To get module records that match the criteria
        $records = $response->getData();

$obj = new  Search_contacts();

Module_name: The API name of the module
Possible_Module_name: leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, price books, quotes, sales orders, purchase orders, invoices, custom, and notes.

Parameter to pass to search record in Zoho Module.

1) criteria :

=> Below criteria are used for searching records.


2) email: search records by email parameter
3) phone : search record by phone parameter
4) page: To get the list of records from the respective pages.
=> Default value for page is 1.
5) per_page : To get the list of records available per page.
=> Default value for page is 200.

Submit a Comment

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


Select Categories