Zoho
Introduction
The JUMP Newsletter Zoho integration will subscribe users on Zoho Campaigns.
You might need to run the php artisan october migration command to ensure that the jump_newsletter_zoho_tokens table is created.
Configuration
Config setup
Register the service - config/services.php
'zoho' => [
'client_id' => env('ZOHO_CLIENT_ID'),
'client_secret' => env('ZOHO_CLIENT_SECRET'),
'list_key' => env('ZOHO_LIST_KEY'),
'zoho_redirect_uri' => env('ZOHO_REDIRECT_URI'),
],
List ID
Zoho Campaign List ID
You will need a campaign list ID where user data will be stored.
- Go to Zoho Campaign Lists
- Click into required list.
- Click "Setup" menu option
- Get your list key and save it as
ZOHO_LIST_KEYin your .env.
Authentication
Zoho CRM API uses the OAuth2.0 protocol for authentication.
To make API calls the application must be authenticated with an access token, which is valid for 1 hour. Refresh token then needs to be used to get a new access token. However, firstly the application has to be granted access to specific scopes with a temporary authorisation token.
Perform one-time authorisation and get client secret
- Go to https://api-console.zoho.eu/ and log in
- Click "Add Client"
- Select "Self Client"
- Set Client Name to be your client's name, e.g. "JUMP"
- Add Homepage URL
- Add Authorized Redirect URIs, e.g. http://localhost:8000/zoho-callback (this endpoint doesn't need any functionality)
- Click "Create"
- Get Client ID and Client Secret from the "Client Secret" tab and save them in your .env file as
ZOHO_CLIENT_IDandZOHO_CLIENT_SECRET - Switch to the "Generate Code" tab
- Enter the required scope separated by commas, e.g.
ZohoCampaigns.contact.UPDATE(this is the scope needed for list subscriptions). Full list of scopes is available here. - Enter a description (it could describe what the scope covers, e.g. "Modules")
- Click "Create"
- Click on "CRM" portal, use the radio box to select your environment
- Click "Create"
- Copy the generated code and save it somewhere: you'll need to use it soon
.env setup
Check you have the following values in your .env.
JUMP_NEWSLETTER_DRIVER=zoho
ZOHO_CLIENT_ID=1000.VLGM... # Client ID from Zoho
ZOHO_CLIENT_SECRET=65e13d8... # Client Secret from Zoho
ZOHO_LIST_KEY=3z5014e.... # Campaign List ID from Zoho
ZOHO_REDIRECT_URI=http://... # Callback URL you provided on Zoho client
Initialise Zoho
Run php artisan command designed to initialise Zoho:
php artisan newsletter:initialise-zoho YOUR_TEMPORARY_AUTHORISATION_CODE
The first set of tokens will be saved in the jump_newsletter_zoho_tokens database table.
You will need to run this command again on your LS instance when you deploy it to UAT / production, so you get your first set of tokens in the new environment.
Usage
Subscribe
try {
NewsletterManager::instance()->subscribe([
'email' => $params->get('email'),
'list_key' => config('services.zoho.list_key'),
]);
} catch (SubscribeException $e) {
throw new Exception('Sorry, there was an error while signing you up to our newsletter. Please try again later');
}
Unsubscribe
// TODO :)
Other Zoho integrations
Zoho provides variety of different services. This particular integration focuses on Zoho Campaigns, but at JUMP we have Zoho CRM implementation which has been built on wesayhowhigh.com website (wesayhowhigh-2023 GH repo).