Skip to content

Installation Guide

Paride Azzari edited this page Aug 24, 2024 · 2 revisions

1 - Installation

Here are the instruction on how to install and setup the Laravel Keap package:

Prerequisites

Laravel Keap requires the following to run:

  • PHP 8.1+
  • Laravel v10.0+

Installation

You can install the Package by running the following commands in your Laravel project directory.

First, install the repository via composer

composer require keapgeek/laravel-keap

Afterwards, run the install command via Artisan to publish the configuration

php artisan keap:install

In the .env file you can add the following lines:

KEAP_CLIENT_KEY=
KEAP_CLIENT_SECRET=

2 - Get the API keys

Before we install the package, we need to create a Keap Developer account and get our API credentials.

To connect to our Keap App, we need to create a Developer Account which will be used to connect create the credentials to use the API.

Create a Developer Account

Click on the link here below (opens in a new tab) a

Create a Developer Account{class="big-button"}{target="_blank"}{style="text-decoration-line: none;"}

Once you have created your account, if you aren't logged in click here to go to Login Page{target="blank"}

Beware that currently this page is really user unfriendly and buggy.

If you have problem setting up an account, try to delete the cache and cookies of your browser.


Generate the API Keys

Once you have logged in, do not mind the wrong call to action in the webpage, it will redirect you to create a new account, which you already have done.

On the top right of the page, you should see your email address, click on it, and then click Apps. Or simply click here:

My Apps Page

Now click on the + NEW APP button on the top right of the page.

Set an App Name and a Description, for example: "DEV App - Brand Name" or "TEST App ...".

In the API Section you will see only one entry Keap 150, click on Enable and then Save at the bottom.

You will see a App created message and a new section will appear with the Key and the Secret.

Add the Keys to Laravel

In the .env file of your Laravel you can add the following lines:

KEAP_CLIENT_KEY="Paste here the Key string"
KEAP_CLIENT_SECRET="Paste here the Secret string"

Sandbox Application

Before we proceed with connecting Laravel to Keap, here's an important clarification:

Developer Account vs. Keap Account:

  • We created a Developer Account to generate API keys. This is different from the Keap account used for logging into the CRM.
  • The developer account is solely for generating API keys.

Creating a Sandbox App

Now we create a Sandbox App.

The sandbox is a "fake" application. It has all the features of a normal one, except that it allows you 250 contacts and 100 emails/month for 3 users.

These sandboxes are wonderful for development and testing, therefore my suggestion is:

  • For Development: connect the Laravel app you use for development to the Keap Sandbox Application;
  • For Production: connect the Laravel app in production to the real Keap Application.

Click here to create a sandbox application:

Create a SandBox Application{class="big-button"}{target="_blank"}{style="text-decoration-line: none;"}

Choose the same application you have for the Sandbox (Pro, Max, Ultimate) and enter your info. They ask for credit cards, but you will not be billed, unless you use faxes.

Fill the form and click on Create App.

Now we are ready to connect this App with your Laravel application.

3 - First Connection

For the first connection, create a Sandbox Application and connect it to your local laravel installation.

How to connect

Keap uses OAuth 2.0. In which you get two tokens for authentication, and you use them to make your requests.

This package takes care of everything, so you do not need to know the details. But if you are a nerd and want to know more (About Oauth).

Just visit the following URI:

/keap/auth

In your browser simply write yourdomain.test/keap/auth.

You will be redirected to a Keap Login page, where you can login with your credentials.

In your admin panel, you can simply add a button that redirects to this route.

Login to Keap

Use the Sandbox credentials if they are not the same.

Login and you will see a dropdown with a list of all the apps you have connected to this account.

Make sure that the name in this section matches the API key you have choosen in your Developer Account. And select the App you want.

Then you can click on Allow.

If everything went well you will simply see a view with "Successfull connection!".

You are connected and you are ready to start working!

Never clear the cache

The package has automatically read the tokens received from Keap and they will be stored in the cache, therefore:

NEVER CLEAR THE CACHE!

or the tokens will be deleted and all the requests will fail, until you login again. Especially in production.

The tokens last for 24 hours. To keap refreshing the tokens you can use the artisan command

php artisan keap:refresh

Automatically refresh the Tokens

To automatically refresh the tokens, go to the App\Console\Kernel.php file, in your laravel project, and add to the schedule function the following line

    protected function schedule(Schedule $schedule): void
    {
        // Other scheduled commands
        $schedule->command('keap:refresh')->twiceDaily(1, 13);
    }

You can program this command to run twice or thrice daily, to keep the tokens alive and working.

Finished

We have connected the app to Keap and we can finally start playing with it. Go to the next page to understanding the basics of the package.

Clone this wiki locally