Skip to content

Commit c34d8a9

Browse files
authored
Merge pull request #7 from zoho/beta
Beta
2 parents b9200da + f340c14 commit c34d8a9

File tree

9 files changed

+139
-30
lines changed

9 files changed

+139
-30
lines changed

README.md

+32-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# ZOHO CRM PHP SDK
22

3+
## Table Of Contents
4+
5+
* [Overview](#overview)
6+
* [Registering a Zoho Client](#registering-a-zoho-client)
7+
* [Environmental Setup](#environmental-setup)
8+
* [Including the SDK in your project](#including-the-sdk-in-your-project)
9+
* [Persistence](#token-persistence)
10+
* [DataBase Persistence](#database-persistence)
11+
* [File Persistence](#file-persistence)
12+
* [Custom Persistence](#custom-persistence)
13+
* [Configuration](#configuration)
14+
* [Initialization](#initializing-the-application)
15+
* [Class Hierarchy](#class-hierarchy)
16+
* [Responses And Exceptions](#responses-and-exceptions)
17+
* [Multi-User support in the PHP SDK](#multi-user-support-in-the-php-sdk)
18+
* [Sample Code](#sdk-sample-code)
19+
320
## Overview
421

522
Zoho CRM PHP SDK offers a way to create client PHP applications that can be integrated with Zoho CRM.
@@ -61,7 +78,7 @@ You can include the SDK to your project using:
6178
- Run the command below:
6279

6380
```sh
64-
composer require zohocrm/php-sdk:3.0.0
81+
composer require zohocrm/php-sdk:3.0.1
6582
```
6683

6784
- The PHP SDK will be installed and a package named vendor will be created in the workspace of your client app.
@@ -82,11 +99,12 @@ Token persistence refers to storing and utilizing the authentication tokens that
8299

83100
### Table of Contents
84101

85-
- DataBase Persistence
102+
- [DataBase Persistence](#database-persistence)
103+
104+
- [File Persistence](#file-persistence)
86105

87-
- File Persistence
106+
- [Custom Persistence](#custom-persistence)
88107

89-
- Custom Persistence
90108

91109
### Implementing OAuth Persistence
92110

@@ -311,20 +329,27 @@ Before you get started with creating your PHP application, you need to register
311329
312330
```php
313331
/*
314-
* autoRefreshFields
332+
* autoRefreshFields (default value is false)
315333
* true - all the modules' fields will be auto-refreshed in the background, every hour.
316334
* 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)
317335
*
318-
* pickListValidation
336+
* pickListValidation (default value is true)
319337
* 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.
320338
* true - the SDK validates the input. If the value does not exist in the pick list, the SDK throws an error.
321339
* false - the SDK does not validate the input and makes the API request with the user’s input to the pick list
340+
*
341+
* enableSSLVerification (default value is true)
342+
* A boolean field to enable or disable curl certificate verification
343+
* true - the SDK verifies the authenticity of certificate
344+
* false - the SDK skips the verification
322345
*/
323346
$autoRefreshFields = false;
324347
325348
$pickListValidation = false;
326349
327-
$sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->build();
350+
$enableSSLVerification = true;
351+
352+
$sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->setSSLVerification($enableSSLVerification)->build();
328353
```
329354
330355
- Create an instance of RequestProxy containing the proxy properties of the user.

src/com/zoho/api/authenticator/OAuthToken.php

+5
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ public function getResponseFromServer($request_params)
311311

312312
curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, Constants::REQUEST_METHOD_POST);
313313

314+
if(!Initializer::getInitializer()->getSDKConfig()->isSSLVerificationEnabled())
315+
{
316+
curl_setopt($curl_pointer, CURLOPT_SSL_VERIFYPEER, false);
317+
}
318+
314319
$result = curl_exec($curl_pointer);
315320

316321
curl_close($curl_pointer);

src/com/zoho/crm/api/SDKConfigBuilder.php

+32-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ class SDKConfigBuilder
1010

1111
private $pickListValidation;
1212

13+
private $enableSSLVerification;
14+
1315
public function __Construct()
1416
{
1517
$this->autoRefreshFields = false;
1618

1719
$this->pickListValidation = true;
20+
21+
$this->enableSSLVerification = true;
1822
}
1923

2024
/**
2125
* This is a setter method to set autoRefreshFields.
22-
* @param autoRefreshFields
26+
* @param autoRefreshFields
2327
*/
2428
public function setAutoRefreshFields(bool $autoRefreshFields)
2529
{
@@ -39,13 +43,24 @@ public function setPickListValidation(bool $pickListValidation)
3943
return $this;
4044
}
4145

46+
/**
47+
* This is a setter method to set enableSSLVerification.
48+
* @param enableSSLVerification
49+
*/
50+
public function setSSLVerification(bool $enableSSLVerification)
51+
{
52+
$this->enableSSLVerification = $enableSSLVerification;
53+
54+
return $this;
55+
}
56+
4257
/**
4358
* The method to build the SDKConfig instance
4459
* @returns An instance of SDKConfig
4560
*/
4661
public function build()
4762
{
48-
return new \com\zoho\crm\api\sdkconfigbuilder\SDKConfig($this->autoRefreshFields, $this->pickListValidation);
63+
return new \com\zoho\crm\api\sdkconfigbuilder\SDKConfig($this->autoRefreshFields, $this->pickListValidation, $this->enableSSLVerification);
4964
}
5065
}
5166

@@ -60,16 +75,21 @@ class SDKConfig
6075

6176
private $pickListValidation;
6277

78+
private $enableSSLVerification;
79+
6380
/**
6481
* Creates an instance of SDKConfig with the given parameters
6582
* @param autoRefreshFields - A boolean representing autoRefreshFields
6683
* @param pickListValidation - A boolean representing pickListValidation
84+
* @param enableSSLVerification - A boolean representing enableSSLVerification
6785
*/
68-
public function __Construct(bool $autoRefreshFields, bool $pickListValidation)
86+
public function __Construct(bool $autoRefreshFields, bool $pickListValidation, bool $enableSSLVerification)
6987
{
7088
$this->autoRefreshFields = $autoRefreshFields;
7189

7290
$this->pickListValidation = $pickListValidation;
91+
92+
$this->enableSSLVerification = $enableSSLVerification;
7393
}
7494

7595
/**
@@ -89,5 +109,14 @@ public function getPickListValidation()
89109
{
90110
return $this->pickListValidation;
91111
}
112+
113+
/**
114+
* This is a getter method to get enableSSLVerification.
115+
* @return A boolean representing enableSSLVerification
116+
*/
117+
public function isSSLVerificationEnabled()
118+
{
119+
return $this->enableSSLVerification;
120+
}
92121
}
93122
?>

src/com/zoho/crm/api/util/APIHTTPConnector.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,21 @@ public function fireRequest($converterInstance)
193193
}
194194

195195
$this->setQueryHeaders($curl_options);
196-
196+
197+
if(!Initializer::getInitializer()->getSDKConfig()->isSSLVerificationEnabled())
198+
{
199+
$curl_options[CURLOPT_SSL_VERIFYPEER] = false;
200+
}
201+
197202
curl_setopt_array($curl_pointer, $curl_options);
198-
203+
199204
SDKLogger::info($this->toString());
200205

201206
$response = array();
202207

203208
$response[Constants::RESPONSE] = curl_exec($curl_pointer);
204209

205-
if (curl_errno($curl_pointer))
210+
if (curl_errno($curl_pointer))
206211
{
207212
$response[Constants::ERROR] = curl_error($curl_pointer);
208213
}

src/com/zoho/crm/api/util/CommonAPIHandler.php

+41-6
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function apiCall($className, $encodeType)
329329
}
330330

331331
$converterInstance = $this->getConverterClassInstance(strtolower($responseContentType));
332-
332+
333333
$returnObject = $converterInstance->getWrappedResponse($response[Constants::RESPONSE], $className);
334334

335335
if ($returnObject !== null)
@@ -393,25 +393,60 @@ private function isExpectedType(Model $model, string $className)
393393
*/
394394
public function getConverterClassInstance($encodeType)
395395
{
396-
switch ($encodeType)
396+
switch ($encodeType)
397397
{
398398
case "application/json":
399399
case "text/plain":
400+
case "application/ld+json":
400401
return new JSONConverter($this);
401402
case "application/xml":
402403
case "text/xml":
403404
return new XMLConverter($this);
404405
case "multipart/form-data":
405406
return new FormDataConverter($this);
406-
case "application/x-download":
407407
case "image/png":
408408
case "image/jpeg":
409-
case "application/zip":
410409
case "image/gif":
411-
case "text/csv":
412410
case "image/tiff":
413-
case "application/octet-stream":
411+
case "image/svg+xml":
412+
case "image/bmp":
413+
case "image/webp":
414+
case "text/csv":
414415
case "text/html":
416+
case "text/css":
417+
case "text/javascript":
418+
case "text/calendar":
419+
case "application/x-download":
420+
case "application/zip":
421+
case "application/pdf":
422+
case "application/java-archive":
423+
case "application/javascript":
424+
case "application/octet-stream":
425+
case "application/xhtml+xml":
426+
case "application/x-bzip":
427+
case "application/msword":
428+
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
429+
case "application/gzip":
430+
case "application/x-httpd-php":
431+
case "application/vnd.ms-powerpoint":
432+
case "application/vnd.rar":
433+
case "application/x-sh":
434+
case "application/x-tar":
435+
case "application/vnd.ms-excel":
436+
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
437+
case "application/x-7z-compressed":
438+
case "audio/mpeg":
439+
case "audio/x-ms-wma":
440+
case "audio/vnd.rn-realaudio":
441+
case "audio/x-wav":
442+
case "audio/3gpp":
443+
case "audio/3gpp2":
444+
case "video/mpeg":
445+
case "video/mp4":
446+
case "video/webm":
447+
case "video/3gpp":
448+
case "video/3gpp2":
449+
case "font/ttf":
415450
return new Downloader($this);
416451
}
417452

src/com/zoho/crm/api/util/Constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class Constants
464464

465465
const FORM_REQUEST_EXCEPTION = "Exception in forming request body : ";
466466

467-
const SDK_VERSION = "3.0.0";
467+
const SDK_VERSION = "3.0.1";
468468

469469
const API_CALL_EXCEPTION = "Exception in current API call execution : ";
470470

src/com/zoho/crm/api/util/Downloader.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,19 @@ public function getResponse($response, $pack)
9696
$responseHeaders = $response[Constants::HEADERS];
9797

9898
$responseContent = $response[Constants::CONTENT];
99-
100-
$contentDisposition = $responseHeaders[Constants::CONTENT_DISPOSITION];
101-
102-
if ($contentDisposition == null)
99+
100+
$contentDisposition = "";
101+
102+
if(array_key_exists(Constants::CONTENT_DISPOSITION, $responseHeaders))
103103
{
104-
$contentDisposition = $responseHeaders[Constants::CONTENT_DISPOSITION1];
105-
}
104+
$contentDisposition = $responseHeaders[Constants::CONTENT_DISPOSITION];
106105

106+
if ($contentDisposition == null)
107+
{
108+
$contentDisposition = $responseHeaders[Constants::CONTENT_DISPOSITION1];
109+
}
110+
}
111+
107112
$fileName = substr($contentDisposition, strrpos($contentDisposition, "'") + 1, strlen($contentDisposition));
108113

109114
if (strpos($fileName, "=") !== false)

src/com/zoho/crm/api/util/JSONConverter.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,14 @@ public function buildName($memberName)
11031103

11041104
$sdkName = lcfirst($name[0]);
11051105

1106-
for ($nameIndex = 1; $nameIndex < count($name); $nameIndex ++)
1106+
for ($nameIndex = 1; $nameIndex < count($name); $nameIndex ++)
11071107
{
1108-
$firstLetterUppercase = ucfirst($name[$nameIndex]);
1108+
$firstLetterUppercase = "";
1109+
1110+
if(strlen(($name[$nameIndex])) > 0)
1111+
{
1112+
$firstLetterUppercase = ucfirst($name[$nameIndex]);
1113+
}
11091114

11101115
$sdkName = $sdkName . $firstLetterUppercase;
11111116
}

src/com/zoho/crm/api/util/Utility.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -843,13 +843,13 @@ public static function fillDataType()
843843
return;
844844
}
845845

846-
$fieldAPINamesString = ["textarea", "text", "website", "email", "phone", "mediumtext","multiselectlookup", "profileimage"];
846+
$fieldAPINamesString = ["textarea", "text", "website", "email", "phone", "mediumtext","multiselectlookup", "profileimage", "autonumber"];
847847

848848
$fieldAPINamesInteger = ["integer"];
849849

850850
$fieldAPINamesBoolean = ["boolean"];
851851

852-
$fieldAPINamesLong = ["long", "bigint", "autonumber"];
852+
$fieldAPINamesLong = ["long", "bigint"];
853853

854854
$fieldAPINamesDouble = ["double", "percent", "lookup", "currency"];
855855

0 commit comments

Comments
 (0)