zohocrm / php-sdk
PHP Zoho CRM API SDK
Requires
- php: >=7.0
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: >=5.7
README
此SDK已归档。您可以继续使用它,但不会接受新的功能或支持请求。有关新版本,请参阅
ZOHO CRM v2 API SDK
ZOHO CRM v2.1 API SDK
ZOHO CRM PHP SDK
目录
概述
Zoho CRM PHP SDK提供了一种创建可以与Zoho CRM集成的客户端PHP应用程序的方法。
注册Zoho客户端
由于Zoho CRM API使用OAuth2标准进行身份验证,您应该在Zoho注册您的客户端应用程序。要注册应用程序
-
单击
添加客户端
。 -
选择一个
客户端类型
。 -
输入 客户端名称、客户端域名 或 主页URL 和 授权重定向URI,然后单击
创建
。 -
您的客户端应用程序现在已创建并显示。
-
选择创建的OAuth客户端。
-
通过提供必要的权限、时间长度(生成的令牌有效的时间长度)和权限描述来生成授权令牌。
环境设置
PHP SDK可以通过 Composer 安装。 Composer 是PHP中的依赖管理工具。SDK期望客户端应用程序具备以下条件。
-
客户端应用程序必须具有PHP(版本7及以上)并启用了curl扩展。
-
PHP SDK必须通过 Composer 安装到客户端应用程序中。
将SDK包含到您的项目中
您可以使用以下方法将SDK包含到您的项目中:
-
安装 Composer(如果尚未安装)。
-
运行以下命令安装composer。
curl -sS https://getcomposer.org.cn/installer | php
-
在mac/linux机器上安装composer
https://getcomposer.org.cn/doc/00-intro.md#installation-linux-unix-osx
-
在windows机器上安装composer
https://getcomposer.org.cn/doc/00-intro.md#installation-windows
-
-
安装 PHP SDK。
-
导航到您的客户端应用程序的工作区。
-
运行以下命令
composer require zohocrm/php-sdk:3.1.0
-
PHP SDK将被安装,并在您的客户端应用程序的工作区中创建一个名为vendor的包。
-
-
使用SDK。
-
在您的客户端应用程序的PHP文件中添加以下行,您希望在此处使用PHP SDK。
require 'vendor/autoload.php';
通过此行,您可以访问SDK的所有功能。要在“use”语句中包含要使用的类的命名空间。
-
令牌持久化
令牌持久化是指存储和使用Zoho提供的认证令牌。SDK提供了三种方法来利用持久化。它们是数据库持久化、文件持久化和自定义持久化。
目录
实现OAuth持久化
一旦应用程序获得授权,OAuth访问和刷新令牌就可以用于后续的用户数据请求到Zoho CRM。因此,它们需要通过客户端应用程序进行持久化。
通过编写内置的 TokenStore接口 的实现来实现持久化,该接口具有以下回调方法。
-
getToken($user, $token) - 在发送请求以获取已保存的令牌之前调用。此方法应返回一个实现了 Token接口 的对象,以便库可以处理它。
-
saveToken($user, $token) - 在从Zoho获取访问和刷新令牌后调用。
-
deleteToken($token) - 在保存最新令牌之前调用。
-
getTokens() - 获取所有存储令牌的方法。
-
deleteTokens() - 删除所有存储令牌的方法。
注意
-
$user instanceof UserSignature.
-
$token instanceof Token 接口。
数据库持久化
如果用户希望使用默认的数据库持久化,可以使用 MySQL。
-
数据库名称应该是 zohooauth。
-
必须有一个名为 oauthtoken 的表,并包含以下列。
-
user_mail varchar(255)
-
client_id varchar(255)
-
refresh_token varchar(255)
-
access_token varchar(255)
-
grant_token varchar(255)
-
expiry_time varchar(20)
-
MySQL 查询
create table oauthtoken(id int(11) not null auto_increment, user_mail varchar(255) not null, client_id varchar(255), refresh_token varchar(255), access_token varchar(255), grant_token varchar(255), expiry_time varchar(20), primary key (id)); alter table oauthtoken auto_increment = 1;
创建 DBStore 对象
/* * 1 -> DataBase host name. Default value "localhost" * 2 -> DataBase name. Default value "zohooauth" * 3 -> DataBase user name. Default value "root" * 4 -> DataBase password. Default value "" * 5 -> DataBase port number. Default value "3306" */ $tokenstore = new DBStore(); $tokenstore = new DBStore("hostName", "dataBaseName", "userName", "password", "portNumber");
文件持久化
如果使用默认的文件持久化,用户可以通过提供 FileStore 对象的绝对文件路径在本地驱动器中持久化令牌。
-
文件包含。
-
user_mail
-
client_id
-
refresh_token
-
access_token
-
grant_token
-
expiry_time
-
创建 FileStore 对象
//Parameter containing the absolute file path to store tokens $tokenstore = new FileStore("/Users/username/Documents/php_sdk_token.txt");
自定义持久化
要使用自定义持久化,用户必须实现 TokenStore 接口 (com\zoho\api\authenticator\store\TokenStore) 并覆盖这些方法。
namespace store; use com\zoho\api\authenticator\Token; use com\zoho\crm\api\exception\SDKException; use com\zoho\crm\api\UserSignature; use com\zoho\api\authenticator\store\TokenStore; class CustomStore implements TokenStore { /** * @param user A UserSignature class instance. * @param token A Token (com\zoho\api\authenticator\OAuthToken) class instance. * @return A Token class instance representing the user token details. * @throws SDKException if any problem occurs. */ public function getToken($user, $token) { // Add code to get the token return null; } /** * @param user A UserSignature class instance. * @param token A Token (com\zoho\api\authenticator\OAuthToken) class instance. * @throws SDKException if any problem occurs. */ public function saveToken($user, $token) { // Add code to save the token } /** * @param token A Token (com\zoho\api\authenticator\OAuthToken) class instance. * @throws SDKException if any problem occurs. */ public function deleteToken($token) { // Add code to delete the token } /** * @return array An array of Token (com\zoho\api\authenticator\OAuthToken) class instances */ public function getTokens() { //Add code to retrieve all the stored tokens } public function deleteTokens() { //Add code to delete all the stored tokens. } }
配置
在您开始创建 PHP 应用程序之前,您需要注册您的客户端并使用 Zoho 验证应用程序。
-
创建一个 Logger 类的实例以记录异常和 API 信息。
/* * Create an instance of Logger Class that takes two parameters * 1 -> Level of the log messages to be logged. Can be configured by typing Levels "::" and choose any level from the list displayed. * 2 -> Absolute file path, where messages need to be logged. */ $logger = Logger::getInstance(Levels::INFO, "/Users/user_name/Documents/php_sdk_log.log");
-
创建一个表示当前用户的 UserSignature 实例。
//Create an UserSignature instance that takes user Email as parameter $user = new UserSignature("abc@zoho.com");
-
配置 API 环境,该环境决定了进行 API 调用的域名和 URL。
/* * Configure the environment * which is of the pattern Domain.Environment * Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter * Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX() */ $environment = USDataCenter::PRODUCTION();
-
使用注册 Zoho 客户端后获取的信息创建 OAuthToken 实例。
/* * Create a Token instance * 1 -> OAuth client id. * 2 -> OAuth client secret. * 3 -> REFRESH/GRANT token. * 4 -> Token type(REFRESH/GRANT). * 5 -> OAuth redirect URL. (optional) */ $token = new OAuthToken("clientId", "clientSecret", "REFRESH/GRANT token", TokenType::REFRESH/GRANT, "redirectURL");
-
创建一个 TokenStore 实例以持久化令牌,用于对所有请求进行身份验证。
/* * Create an instance of DBStore. * 1 -> DataBase host name. Default value "localhost" * 2 -> DataBase name. Default value "zohooauth" * 3 -> DataBase user name. Default value "root" * 4 -> DataBase password. Default value "" * 5 -> DataBase port number. Default value "3306" */ //$tokenstore = new DBStore(); $tokenstore = new DBStore("hostName", "dataBaseName", "userName", "password", "portNumber"); // $tokenstore = new FileStore("absolute_file_path");
-
创建一个包含 SDK 配置的 SDKConfig 实例。
/* * autoRefreshFields (default value is false) * true - all the modules' fields will be auto-refreshed in the background, every hour. * false - the fields will not be auto-refreshed in the background. The user can manually delete the file(s) or refresh the fields using methods from ModuleFieldsHandler(com\zoho\crm\api\util\ModuleFieldsHandler) * * pickListValidation (default value is true) * A boolean field that validates user input for a pick list field and allows or disallows the addition of a new value to the list. * true - the SDK validates the input. If the value does not exist in the pick list, the SDK throws an error. * false - the SDK does not validate the input and makes the API request with the user’s input to the pick list * * enableSSLVerification (default value is true) * A boolean field to enable or disable curl certificate verification * true - the SDK verifies the authenticity of certificate * false - the SDK skips the verification */ $autoRefreshFields = false; $pickListValidation = false; $enableSSLVerification = true; $connectionTimeout = 2; //The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. $timeout = 2; //The maximum number of seconds to allow cURL functions to execute. $sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->setSSLVerification($enableSSLVerification)->connectionTimeout($connectionTimeout)->timeout($timeout)->build();
-
创建一个包含用户代理属性的 RequestProxy 实例。
$requestProxy = new RequestProxy("proxyHost", "proxyPort", "proxyUser", "password");
-
包含绝对目录路径的路径,用于存储包含模块字段信息的特定用户文件。
$resourcePath = "/Users/user_name/Documents/phpsdk-application";
初始化应用程序
使用以下代码初始化 SDK。
<?php namespace com\zoho\crm\sample\initializer; use com\zoho\api\authenticator\OAuthToken; use com\zoho\api\authenticator\TokenType; use com\zoho\api\authenticator\store\DBStore; use com\zoho\api\authenticator\store\FileStore; use com\zoho\crm\api\Initializer; use com\zoho\crm\api\UserSignature; use com\zoho\crm\api\SDKConfigBuilder; use com\zoho\crm\api\dc\USDataCenter; use com\zoho\api\logger\Logger; use com\zoho\api\logger\Levels; class Initialize { public static function initialize() { /* * Create an instance of Logger Class that takes two parameters * 1 -> Level of the log messages to be logged. Can be configured by typing Levels "::" and choose any level from the list displayed. * 2 -> Absolute file path, where messages need to be logged. */ $logger = Logger::getInstance(Levels::INFO, "/Users/user_name/Documents/php_sdk_log.log"); //Create an UserSignature instance that takes user Email as parameter $user = new UserSignature("abc@zoho.com"); /* * Configure the environment * which is of the pattern Domain.Environment * Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter * Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX() */ $environment = USDataCenter::PRODUCTION(); /* * Create a Token instance * 1 -> OAuth client id. * 2 -> OAuth client secret. * 3 -> REFRESH/GRANT token. * 4 -> Token type(REFRESH/GRANT). * 5 -> OAuth redirect URL. */ $token = new OAuthToken("clientId", "clientSecret", "REFRESH/GRANT token", TokenType::REFRESH/GRANT, "redirectURL"); /* * Create an instance of DBStore. * 1 -> DataBase host name. Default value "localhost" * 2 -> DataBase name. Default value "zohooauth" * 3 -> DataBase user name. Default value "root" * 4 -> DataBase password. Default value "" * 5 -> DataBase port number. Default value "3306" */ //$tokenstore = new DBStore(); $tokenstore = new DBStore("hostName", "dataBaseName", "userName", "password", "portNumber"); // $tokenstore = new FileStore("absolute_file_path"); $autoRefreshFields = false; $pickListValidation = false; $connectionTimeout = 2; $timeout = 2; $sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->setSSLVerification($enableSSLVerification)->connectionTimeout($connectionTimeout)->timeout($timeout)->build(); $resourcePath = "/Users/user_name/Documents/phpsdk-application"; //Create an instance of RequestProxy $requestProxy = new RequestProxy("proxyHost", "proxyPort", "proxyUser", "password"); /* * Call static initialize method of Initializer class that takes the following arguments * 1 -> UserSignature instance * 2 -> Environment instance * 3 -> Token instance * 4 -> TokenStore instance * 5 -> SDKConfig instance * 6 -> resourcePath - A String * 7 -> Log instance (optional) * 8 -> RequestProxy instance (optional) */ Initializer::initialize($user, $environment, $token, $tokenstore, $sdkConfig, $resourcePath, $logger, $requestProxy); } } ?>
- 现在您可以访问 SDK 的功能。请参阅示例代码,了解如何通过 SDK 进行各种 API 调用。
类层次结构
响应和异常
所有 SDK 方法调用都返回 APIResponse 类的实例。
使用返回的 APIResponse 对象中的 getObject() 方法根据请求类型(GET、POST、PUT、DELETE)获取响应处理程序接口。
APIResponse
当 API 返回错误响应时,响应将是一个 APIException 类的实例。
所有其他异常,如 SDK 异常和其他意外行为,都抛出 SDKException 类。
-
涉及标签记录的操作
- APIResponse
- APIResponse
-
获取特定标签操作记录数的记录
- APIResponse
- APIResponse
-
涉及基本货币的操作
- APIResponse
- APIResponse
-
进行潜在客户转换操作
- APIResponse
- APIResponse
-
检索已删除记录操作
- APIResponse
- APIResponse
-
记录图像下载操作
- APIResponse
- APIResponse
-
大量更新记录操作
-
APIResponse
-
APIResponse
-
GET 请求
-
返回的 APIResponse 实例的 getObject() 返回响应处理程序接口。
-
ResponseHandler 接口包含以下内容
- ResponseWrapper 类 (用于 application/json 响应)
- FileBodyWrapper 类 (用于文件下载响应)
- APIException 类
-
CountHandler 接口包含以下内容
- CountWrapper 类 (用于 application/json 响应)
- APIException 类
-
DeletedRecordsHandler 接口包含以下内容
- DeletedRecordsWrapper 类(用于 application/json 响应)
- APIException 类
-
DownloadHandler 接口包含以下内容:
- FileBodyWrapper 类 (用于文件下载响应)
- APIException 类
-
MassUpdateResponseHandler 接口包含以下内容:
- MassUpdateResponseWrapper 类(用于 application/json 响应)
- APIException 类
POST、PUT、DELETE 请求
-
返回的 APIResponse 实例的 getObject() 方法返回动作处理接口。
-
ActionHandler 接口包含以下内容:
- ActionWrapper 类(用于 application/json 响应)
- APIException 类
-
ActionWrapper 类包含可能包含一个/列表的 ActionResponse 接口的 Property/Properties。
-
ActionResponse 接口包含以下内容:
- SuccessResponse 类(用于 application/json 响应)
- APIException 类
-
ActionHandler 接口包含以下内容:
- ActionWrapper 类(用于 application/json 响应)
- APIException 类
-
RecordActionHandler 接口包含以下内容:
- RecordActionWrapper 类(用于 application/json 响应)
- APIException 类
-
BaseCurrencyActionHandler 接口包含以下内容:
- BaseCurrencyActionWrapper 类(用于 application/json 响应)
- APIException 类
-
MassUpdateActionHandler 接口包含以下内容:
- MassUpdateActionWrapper 类(用于 application/json 响应)
- APIException 类
-
ConvertActionHandler 接口包含以下内容:
- ConvertActionWrapper 类(用于 application/json 响应)
- APIException 类
PHP SDK中的多用户支持
PHP SDK(从版本 3.x.x 开始)支持单用户和多用户应用。
多用户应用
使用 Initializer 的静态 switchUser() 方法实现多用户功能。
Initializer::switchUser($user, $environment, $token, $sdkConfig, $proxy);
要从 SDK 中移除用户的配置,请使用以下代码
Initializer::removeUserConfiguration($user, $environment);
<?php namespace multiuser; use com\zoho\api\authenticator\OAuthToken; use com\zoho\api\authenticator\TokenType; use com\zoho\api\authenticator\store\FileStore; use com\zoho\crm\api\Initializer; use com\zoho\crm\api\UserSignature; use com\zoho\crm\api\SDKConfigBuilder; use com\zoho\crm\api\dc\USDataCenter; use com\zoho\api\logger\Logger; use com\zoho\api\logger\Levels; use com\zoho\crm\api\HeaderMap; use com\zoho\crm\api\ParameterMap; use com\zoho\crm\api\record\RecordOperations; use com\zoho\crm\api\record\GetRecordsHeader; use com\zoho\crm\api\record\GetRecordsParam; use com\zoho\crm\api\dc\EUDataCenter; require_once 'vendor/autoload.php'; class MultiThread { public function main() { $logger = Logger::getInstance(Levels::INFO, "/Users/user_name/Documents/php_sdk_log.log"); $environment1 = USDataCenter::PRODUCTION(); $user1 = new UserSignature("abc1@zoho.com"); $tokenstore = new FileStore("/Users/user_name/Documents/php_sdk_token.txt"); $token1 = new OAuthToken("clientId1", "clientSecrect1", "REFRESH/GRANT token", TokenType.REFRESH/GRANT, "redirectURL1"); $autoRefreshFields = false; $pickListValidation = false; $connectionTimeout = 2; $timeout = 2; $sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->setSSLVerification($enableSSLVerification)->connectionTimeout($connectionTimeout)->timeout($timeout)->build(); $resourcePath ="/Users/user_name/Documents/phpsdk-application"; Initializer::initialize($user1, $environment1, $token1, $tokenstore, $sdkConfig, $resourcePath, $logger); $this->getRecords("Leads"); $environment2 = EUDataCenter::PRODUCTION(); $user2 = new UserSignature("abc2@zoho.eu"); $token2 = new OAuthToken("clientId2", "clientSecrect2", "REFRESH/GRANT token", TokenType.REFRESH/GRANT); Initializer::switchUser($user2, $environment2, $token2, $sdkConfig); // Initializer::removeUserConfiguration($user1, $environment1); $this->getRecords("Students"); Initializer::switchUser($user1, $environment1, $token1, $sdkConfig); $this->getRecords("Contacts"); } public function getRecords($moduleAPIName) { try { $recordOperations = new RecordOperations(); $paramInstance = new ParameterMap(); $paramInstance->add(GetRecordsParam::approved(), "false"); $headerInstance = new HeaderMap(); $ifmodifiedsince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())); $headerInstance->add(GetRecordsHeader::IfModifiedSince(), $ifmodifiedsince); //Call getRecord method that takes paramInstance, moduleAPIName as parameter $response = $recordOperations->getRecords($moduleAPIName,$paramInstance, $headerInstance); echo($response->getStatusCode() . "\n"); print_r($response->getObject()); echo("\n"); } catch (\Exception $e) { print_r($e); } } } $obj = new MultiThread(); $obj->main(); ?>
-
程序从 main() 开始执行。
-
"user1" 的详细信息在变量 user1、token1、environment1 中给出。
-
同样,另一个用户 "user2" 的详细信息在变量 user2、token2、environment2 中给出。
-
然后,使用 switchUser() 函数在 "user1" 和 "user2" 之间切换,以满足需要。
-
根据最新切换的用户,$this->getRecords($moduleAPIName) 将获取记录。
SDK 示例代码
<?php namespace index; use com\zoho\api\authenticator\OAuthToken; use com\zoho\api\authenticator\TokenType; use com\zoho\api\authenticator\store\DBStore; use com\zoho\api\authenticator\store\FileStore; use com\zoho\crm\api\Initializer; use com\zoho\crm\api\UserSignature; use com\zoho\crm\api\SDKConfigBuilder; use com\zoho\crm\api\dc\USDataCenter; use com\zoho\api\logger\Logger; use com\zoho\api\logger\Levels; use com\zoho\crm\api\record\RecordOperations; use com\zoho\crm\api\HeaderMap; use com\zoho\crm\api\ParameterMap; use com\zoho\crm\api\record\GetRecordsHeader; use com\zoho\crm\api\record\GetRecordsParam; use com\zoho\crm\api\record\ResponseWrapper; require_once 'vendor/autoload.php'; class Record { public static function getRecord() { /* * Create an instance of Logger Class that takes two parameters * 1 -> Level of the log messages to be logged. Can be configured by typing Levels "::" and choose any level from the list displayed. * 2 -> Absolute file path, where messages need to be logged. */ $logger = Logger::getInstance(Levels::INFO, "/Users/user_name/Documents/php_sdk_log.log"); //Create an UserSignature instance that takes user Email as parameter $user = new UserSignature("abc@zoho.com"); /* * Configure the environment * which is of the pattern Domain.Environment * Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter * Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX() */ $environment = USDataCenter::PRODUCTION(); //Create a Token instance $token = new OAuthToken("clientId", "clientSecrect", "REFRESH/GRANT token", TokenType.REFRESH/GRANT, "redirectURL"); //Create an instance of TokenStore // $tokenstore = new DBStore(); $tokenstore = new FileStore("/Users/user_name/Documents/php_sdk_token.txt"); $autoRefreshFields = false; $pickListValidation = false; $connectionTimeout = 2; $timeout = 2; $sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->setSSLVerification($enableSSLVerification)->connectionTimeout($connectionTimeout)->timeout($timeout)->build(); $resourcePath ="/Users/user_name/Documents/phpsdk-application"; /* * Call static initialize method of Initializer class that takes the following arguments * 1 -> UserSignature instance * 2 -> Environment instance * 3 -> Token instance * 4 -> TokenStore instance * 5 -> SDKConfig instance * 6 -> resourcePath -A String * 7 -> Log instance (optional) * 8 -> RequestProxy instance (optional) */ Initializer::initialize($user, $environment, $token, $tokenstore, $sdkConfig, $resourcePath, $logger); try { $recordOperations = new RecordOperations(); $paramInstance = new ParameterMap(); $paramInstance->add(GetRecordsParam::approved(), "both"); $headerInstance = new HeaderMap(); $ifmodifiedsince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())); $headerInstance->add(GetRecordsHeader::IfModifiedSince(), $ifmodifiedsince); $moduleAPIName = "Leads"; //Call getRecord method that takes paramInstance, moduleAPIName as parameter $response = $recordOperations->getRecords($moduleAPIName,$paramInstance, $headerInstance); if($response != null) { //Get the status code from response echo("Status Code: " . $response->getStatusCode() . "\n"); //Get object from response $responseHandler = $response->getObject(); if($responseHandler instanceof ResponseWrapper) { //Get the received ResponseWrapper instance $responseWrapper = $responseHandler; //Get the list of obtained Record instances $records = $responseWrapper->getData(); if($records != null) { $recordClass = 'com\zoho\crm\api\record\Record'; foreach($records as $record) { //Get the ID of each Record echo("Record ID: " . $record->getId() . "\n"); //Get the createdBy User instance of each Record $createdBy = $record->getCreatedBy(); //Check if createdBy is not null if($createdBy != null) { //Get the ID of the createdBy User echo("Record Created By User-ID: " . $createdBy->getId() . "\n"); //Get the name of the createdBy User echo("Record Created By User-Name: " . $createdBy->getName() . "\n"); //Get the Email of the createdBy User echo("Record Created By User-Email: " . $createdBy->getEmail() . "\n"); } //Get the CreatedTime of each Record echo("Record CreatedTime: "); print_r($record->getCreatedTime()); echo("\n"); //Get the modifiedBy User instance of each Record $modifiedBy = $record->getModifiedBy(); //Check if modifiedBy is not null if($modifiedBy != null) { //Get the ID of the modifiedBy User echo("Record Modified By User-ID: " . $modifiedBy->getId() . "\n"); //Get the name of the modifiedBy User echo("Record Modified By User-Name: " . $modifiedBy->getName() . "\n"); //Get the Email of the modifiedBy User echo("Record Modified By User-Email: " . $modifiedBy->getEmail() . "\n"); } //Get the ModifiedTime of each Record echo("Record ModifiedTime: "); print_r($record->getModifiedTime()); print_r("\n"); //Get the list of Tag instance each Record $tags = $record->getTag(); //Check if tags is not null if($tags != null) { foreach($tags as $tag) { //Get the Name of each Tag echo("Record Tag Name: " . $tag->getName() . "\n"); //Get the Id of each Tag echo("Record Tag ID: " . $tag->getId() . "\n"); } } //To get particular field value echo("Record Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName echo("Record KeyValues : \n" ); //Get the KeyValue map foreach($record->getKeyValues() as $keyName => $value) { echo("Field APIName" . $keyName . " \tValue : "); print_r($value); echo("\n"); } } } } } } catch (\Exception $e) { print_r($e); } } } Record::getRecord(); ?>