Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Record
- {
- public static function getRecord()
- {
- /**
- * Configuration variables
- */
- $autoRefreshFields = false; // all the modules' fields will be auto-refreshed in the background, every hour.
- $pickListValidation = false; // validates user input for a pick list field and allows or disallows the addition of a new value to the list.
- $enableSSLVerification = true; // enable or disable curl certificate verification
- $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.
- $resourcePath = realpath(__DIR__) . '/phpsdk-application/'; // Absolute directory path to store user specific files containing module fields information.
- /* Path of the file that will store the OAuth token */
- $token_file_path = realpath(__DIR__) . '/php_sdk_token.txt';
- /* OAuth token persistance */
- $token_store = new FileStore($token_file_path);
- /* Logger for exception, and API feedbacks */
- $log_file_path = realpath(__DIR__) . '/php_sdk_log.log';
- $logger = Logger::getInstance(Levels::INFO, $log_file_path);
- /* Instance of UserSignature that identifies the current user */
- $user = new UserSignature('MY ACCOUNT EMAIL');
- /* Configures API environment which decides the domain and the URL to make API calls. */
- $environment = USDataCenter::PRODUCTION();
- /* Creates an instance of OAuthToken using the information got after registering your Zoho client */
- $token = new OAuthToken("MY CLIENT ID", "MY CLIENT SECRET", "MY GRANT TOKEN FROM ZOHO SELF CLIENT", TokenType::REFRESH, "http://localhost/poc-zoho/");
- /* Instance of SDKConfig containing SDK configurations */
- $sdkConfig = (new SDKConfigBuilder())
- ->setAutoRefreshFields($autoRefreshFields)
- ->setPickListValidation($pickListValidation)
- ->setSSLVerification($enableSSLVerification)
- ->connectionTimeout($connectionTimeout)
- ->timeout($timeout)
- ->build();
- /* (useless ?) Instance of RequestProxy containing the proxy properties of the user. */
- // $requestProxy = new RequestProxy("proxyHost", "proxyPort", "proxyUser", "password");
- Initializer::initialize($user, $environment, $token, $token_store, $sdkConfig, $resourcePath, $logger);
- /**
- * Things getting serious here
- */
- try {
- /* Output instance */
- $recordOperations = new RecordOperations();
- /* Parameters instance */
- $paramInstance = new ParameterMap();
- $paramInstance->add(GetRecordsParam::approved(), "both");
- /* ? Request headers */
- $headerInstance = new HeaderMap();
- /* ??? Get only records modified since a given date ???? */
- $ifmodifiedsince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
- $headerInstance->add(GetRecordsHeader::IfModifiedSince(), $ifmodifiedsince);
- /* Module name is available here : https://crm.zoho.com/crm/orgXXXXX/settings/modules */
- $moduleAPIName = "Contacts";
- /* Query and its response */
- $response = $recordOperations->getRecords($moduleAPIName, $paramInstance, $headerInstance); // Call getRecord method that takes paramInstance, moduleAPIName as parameter
- } catch (\Exception $e) {
- print_r($e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment