minstersoft/activecampaign

ActiveCampaign API connector for APIv3 For PHP 7.0

2.0.0 2021-08-06 11:07 UTC

This package is auto-updated.

Last update: 2024-06-06 17:03:34 UTC


README

License

This package provides a PHP SDK for the ActiveCampaign API (v3).

Forked from testmonitor/activecampaign

For more information on the ActiveCampaign API, refer to their developer documentation.

Table of Contents

Installation

This package can be installed through Composer:

$ composer require minstersoft/activecampaign

To install and dev locally:

1. Add version in composer.json.

{
"..": "...",
"version": "1.0.0",
"...": "..."
}

2. Replace the url with your local path and run the command.

$ composer config repositories.minstersoft/activecampaign '{"type": "path", "url": "/home/vagrant/activecampaign"}'
$ composer require minstersoft/activecampaign

Make sure to use Composer's autoload:

require __DIR__.'/../vendor/autoload.php';

Add 'use' before class name

use Minstersoft\ActiveCampaign\ActiveCampaign;

class ClassName { 
 //...
}

Start by creating a new instance:

$activeCampaign = new ActiveCampaign(ACTIVE_CAMPAIGN_URL, ACTIVE_CAMPAIGN_KEY);

Your API key can be found in your account on the Settings page under the "Developer" tab.

Usage

Once instantiated, you can simply call one of the methods provided by the SDK:

$activeCampaign->contacts();

This will provide you with a list of available contacts.

To create a contact, you can use the createContact method:

$contact = $activeCampaign->createContact(
    'email' => 'johndoe@example.com',
    'firstName' => 'John',
    'lastName' => 'Doe',
);

When the request was successful, $contact will contain a Contact object with the contact details.

To retrieve an existing contact or create it when it is missing:

$contact = $activeCampaign->findOrCreateContact(
    'email' => 'johndoe@example.com',
    'firstName' => 'John',
    'lastName' => 'Doe',
);

When the request was successful, $contact will contain a Contact object with the contact details.

Tests

The package contains integration tests. You can run them using PHPUnit.

$ vendor/bin/phpunit

Changelog

Refer to CHANGELOG for more information.

License

The MIT License (MIT). Refer to the License for more information.