This library is a simple PHP wrapper for the ActiveCampaign API v3.
Install the latest version with Composer:
composer require metaline/activecampaign-sdk
This project works with PHP 5.6+ or 7.1+.
You also need a URL and a KEY to access the ActiveCampaign APIs. These parameters are specific to your ActiveCampaign account. You can find them under Settings / Developer section of your profile.
First you need to create an instance of the Client:
<?php
require __DIR__ . '/vendor/autoload.php';
use MetaLine\ActiveCampaign\Client;
$apiURL = 'https://<YOUR ACCOUNT>.api-us1.com';
$apiKEY = 'super-secret-key'; // Never publish this key!
$client = new Client($apiURL, $apiKEY);
Now you are ready to talk to the ActiveCampaign API. For example, you can retrieves all contacts:
$result = $client->get('contacts');
$result = $client->post('contacts', [
'contact' => [
'email' => '[email protected]',
'firstName' => 'John',
'lastName' => 'Doe',
'phone' => '7223224241',
]
]);
$result = $client->delete('contacts/' . $contactId);
And so on.
Check the ActiveCampaign documentation for the other APIs.
All Client methods return a Result
object, that itβs a simple value object:
if ($result->isSuccessful()) {
$data = $result->getData();
} else {
$errors = $result->getErrors();
}
Debug the result to discover how to proceed.
This project is licensed under the MIT License. See the LICENSE file for details.