#PHP SDK for Zoho CRM
----------------------
PHP SDK for Zoho CRM APIs provides wrapper for Zoho CRM APIs. Hence invoking a Zoho CRM API from your client application is just a method call.It supports both single user as well as multi user authentication.
Registering a Zoho Client
-------------------------
Since Zoho CRM APIs are authenticated with OAuth2 standards, you should register your client app with Zoho. To register your app:
1) Visit this page [https://accounts.zoho.com/developerconsole](https://accounts.zoho.com/developerconsole).
2) Click on `Add Client ID`.
3) Enter Client Name, Client Domain and Redirect URI then click `Create`.
4) Your Client app would have been created and displayed by now.
5) The newly registered app's Client ID and Client Secret can be found by clicking `Options` → `Edit`.
(Options is the three dot icon at the right corner).
Setting Up
----------
PHP SDK is installable through `composer`. Composer is a tool for dependency management in PHP. SDK expects the following from the client app.
>Client app must have PHP 5.6 or above with curl extension enabled.
> PHP SDK must be installed into client app though composer.
The function ZCRMRestClient::initialize($configuration) must be called on startup of app.
>$configuration - Contains the configuration details as a key-value pair.
Token persistence handling (storing and utilizing the oauth tokens) can be done in three ways. File, DB and Custom persistence.
Installation of SDK through composer
------------------------------------
Install Composer(if not installed)
Run this command to install the composer
>curl -sS https://getcomposer.org/installer | php
To make the composer accessible globally, follow the instructions from the link below
To install composer on mac/ linux machine:
>https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
To install composer on windows machine:
>https://getcomposer.org/doc/00-intro.md#installation-windows
Install PHP SDK
---------------
Install PHP SDK
Here's how you install the SDK:
1) Navigate to the workspace of your client app
2) Run the command below:
>composer require zohocrm/php-sdk
Hence, the PHP SDK would be installed and a package named 'vendor' would be created in the workspace of your client app.
Configurations
--------------
To access the CRM services through SDK, the client application must be first authenticated. This can be done by passing a key-value configuration pair to the initialization process.
>The $configuration array must be created. It will contain the authentication credentials required.
The configuration array must then be passed using the "ZCRMRestClient::initialize($configuration); ".
The user must pass the configuration values as php array(key-value pair) as argument to the ZCRMRestclient::initialize($configuration); function. Below is the list of keys that are to be in the array.
Mandatory keys
>client_id
client_secret
redirect_uri
currentUserEmail
Optional keys
>applicationLogFilePath
sandbox
apiBaseUrl
apiVersion
access_type
accounts_url
persistence_handler_class
token_persistence_path
db_port
db_username
db_password
client_id, client_secret and redirect_uri are your OAuth client’s configurations that you get after registering your Zoho client.
currentUserEmail - In case of single user, this configuration can be set using "ZCRMRestClient->setCurrentUser()".
access_type must be set to offline only because online OAuth client is not supported by the PHP SDK as of now.
apiBaseUrl - Url to be used when calling an API. It is used to denote the domain of the user. Url may be:
www.zohoapis.com (default)
www.zohoapis.eu
www.zohoapis.com.cn
apiVersion is "v2".
accounts_url - Default value set as US domain. The value can be changed based on your domain(EU,CN).
accounts.zoho.com
accounts.zoho.eu
accounts.zoho.com.cn
sandbox - To make API calls to sandbox account , please change the value of following key to true. By default the value is false.
applicationLogFilePath - The SDK stores the log information in a file.
The file path of the folder must be specified in the key and the SDK automatically creates the file. The default file name is the ZCRMClientLibrary.log.
In case the path isn't specified, the log file will be created inside the project.
persistence_handler_class is the implementation of the ZohoOAuthPersistenceInterface.
>If the Optional keys are not specified, their default values will be assigned automatically.
>The 'apiBaseUrl' and 'accounts_url' are mandatory in case the user is not in the "com" domain.
Initialization
--------------
The app would be ready to be initialized after defining the configuration array. The user can now proceed to generate the required tokens to run the app.
The generation of the grant token can be done using two methods.
>Self-Client
>Redirection-based code generation
We will be using the self-client option here to demonstrate the process.
Generating self-authorized grant token
--------------------------------------
For self client apps, the self authorized grant token should be generated from the Zoho Developer Console (https://accounts.zoho.com/developerconsole)
>1) Visit https://accounts.zoho.com/developerconsole
2) Click Options → Self Client of the client for which you wish to authorize.
3) Enter one or more(comma separated) valid Zoho CRM scopes, that you wish to authorize, in the “Scope” field and choose a time of expiry.
4) Copy the grant token.
5) Generate refresh_token from grant token by using below URL
>https://accounts.zoho.com/oauth/v2/token?code={grant_token}&redirect_uri={redirect_uri}&client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code
It's a POST request
Copy the refresh_token for backup
Please note that the generated grant token is valid only for the stipulated time you choose while generating it. Hence, refresh token should be generated within that time.
Generating access token
-----------------------
Access token can be generated by grant token or refresh token. Following any one of the two methods is sufficient.
Access Token from grant token:
------------------------------------
The following code snippet should be executed from your main class to get access token. Please paste the copied grant token in the string literal mentioned below. This is a one-time process.
>$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
$oAuthClient = ZohoOAuth::getClientInstance();
$grantToken = "paste_the_self_authorized_grant_token_here";
$oAuthTokens = $oAuthClient->generateAccessToken($grantToken);
Access Token from refresh token:
------------------------------------
The following code snippet should be executed from your main class to get access token. Please paste the copied refresh token in the string literal mentioned below. This is a one-time process.
>$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
$oAuthClient = ZohoOAuth::getClientInstance();
$refreshToken = "paste_the_refresh_token_here";
$userIdentifier = "provide_user_identifier_like_email_here";
$oAuthTokens = $oAuthClient->generateAccessTokenFromRefreshToken($refreshToken,$userIdentifier);
Upon successful execution of the above code snippet, the generated access token and given refresh token would have been persisted through our persistence handler class.
Once the OAuth tokens have been persisted, subsequent API calls would use the persisted access and refresh tokens. The SDK will take care of refreshing the access token using refresh token, as and when required.
App Startup
-----------
The SDK requires the following line of code invoked every time your client app is started.
>
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v2.1.3.zip
共147个文件
php:114个
scss:12个
svg:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 81 浏览量
2022-04-14
15:50:10
上传
评论
收藏 275KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v2.1.3 WooCommerce and Zoho CRM Connector Pro Woocommerce和Zoho CRM Connector Pro" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v2.1.3.zip (147个子文件)
CHANGELOG 3KB
admin.css 23KB
admin.min.css 19KB
.gitignore 48B
admin.js 3KB
installed.json 1KB
composer.json 487B
composer.json 61B
LICENSE 1KB
composer.lock 2KB
admin.css.map 4KB
README.md 16KB
module.php 91KB
organization.php 73KB
woocommerce-and-zoho-crm-connector-pro.php 58KB
ZCRMModule.php 36KB
OrganizationAPIHandler.php 36KB
record.php 32KB
bulkapi.php 31KB
ZCRMOrganization.php 28KB
ModuleAPIHandler.php 28KB
ZCRMRecord.php 27KB
ZCRMUser.php 25KB
EntityAPIHandler.php 23KB
PP_Zoho_API.class.php 19KB
RelatedListAPIHandler.php 18KB
ZCRMField.php 18KB
rest.php 18KB
TagAPIHandler.php 17KB
MassEntityAPIHandler.php 17KB
BulkWriteAPIHandler.php 15KB
ClassLoader.php 13KB
MetaDataAPIHandler.php 13KB
BulkReadAPIHandler.php 13KB
tagAPI.php 12KB
BulkAPIHandler.php 12KB
ZCRMBulkWrite.php 12KB
PP_Zoho_API_v1.class.php 11KB
ZCRMModuleRelation.php 11KB
APIRequest.php 10KB
ZCRMNote.php 10KB
ZCRMCustomView.php 10KB
VariableAPIHandler.php 10KB
EDD_SL_Plugin_Updater.php 10KB
ZCRMAttachment.php 9KB
ZCRMBulkRead.php 9KB
potentials.php 9KB
connection.php 8KB
accounts.php 8KB
ZCRMInventoryLineItem.php 8KB
CommonAPIResponse.php 8KB
customeview.php 8KB
ZCRMTag.php 7KB
ZCRMProfile.php 7KB
ZohoHTTPConnector.php 7KB
ZCRMLayout.php 7KB
FileAPIResponse.php 7KB
ZohoOAuth.php 6KB
ZohoOAuthClient.php 6KB
ZCRMModuleRelatedList.php 6KB
BulkAPIResponse.php 6KB
contacts.php 5KB
ZCRMBulkWriteResource.php 5KB
leads.php 5KB
BulkResponse.php 5KB
ZCRMRestClient.php 5KB
APIResponse.php 5KB
EntityResponse.php 4KB
ZohoOAuthHTTPConnector.php 4KB
ZohoOAuthPersistenceHandler.php 4KB
APIConstants.php 4KB
VariableGroupAPIHandler.php 4KB
ZCRMTrashRecord.php 4KB
ZCRMConfigUtil.php 4KB
ResponseInfo.php 4KB
ZCRMUserCustomizeInfo.php 4KB
ZCRMEventParticipant.php 4KB
ZCRMBulkWriteFileStatus.php 4KB
ZohoOAuthPersistenceByFile.php 4KB
ZCRMBulkWriteFieldMapping.php 3KB
ZCRMPermission.php 3KB
ZCRMBulkQuery.php 3KB
ZCRMBulkCriteria.php 3KB
APIHandler.php 3KB
ZCRMSection.php 3KB
ZCRMRole.php 3KB
processing.php 3KB
ZCRMCustomViewCriteria.php 3KB
ZCRMLeadConvertMappingField.php 3KB
ZCRMProfileCategory.php 3KB
ZCRMUserTheme.php 3KB
order.php 3KB
ZCRMPriceBookPricing.php 3KB
ZCRMBulkResult.php 3KB
ZCRMPickListValue.php 3KB
ZCRMLeadConvertMapping.php 2KB
ZCRMLookupField.php 2KB
ZCRMVariable.php 2KB
ZCRMJunctionRecord.php 2KB
PP_WCZCP_ZohoOAuthPersistenceHandler.php 2KB
共 147 条
- 1
- 2
资源评论
Lee达森
- 粉丝: 966
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功