This is an ActiveCampaign API v3 Wrapper for PHP 7.0+. This PHP SDK contains methods for easily interacting with the ActiveCampaign API. Below there are some examples to get you started. For additional examples and explanations, see the documentation.
The structure is a little bit different than written in the official documentation. We've two logical module levels instead of one: Module / Resource. (To organize resources into logical groups.)
deals
→ Deals / Deals
The E-Commerce functions available under Ecommerce module instead of Deep Data group. (To be more trivial and to prepare for more resources in the future, like products.)
ecomCustomers
→ Ecommerce / Customers
To be able to use ActiveCampaign API you need the API URL and the API Key belong to your account. You can find this information in your account under Settings / Developer, API Access section.
API URL looks like this: https://{{account}}.api-us1.com
API Key looks like this: d41d8cd98f00b204e9800998ecf8427ed41d8cd98f00b204e9800998ecf8427ed41d8cd9
Settings URL: https://{{account}}.activehosted.com/admin/main.php?action=settings#tab_api
To install this wrapper, you need to use Composer in your project. If you are not using Composer yet, here's how to install:
curl -sS https://getcomposer.org/installer | php
composer require balint-horvath/activecampaign-php
php composer.phar require balint-horvath/activecampaign-php
You should always use the autoloader of Composer in your application to automatically load the your dependencies. All examples assumes you've already have included in your file:
require 'vendor/autoload.php';
use BalintHorvath\ActiveCampaign;
Creating a new instance with API URL and Key.
Later we'll refer for it as $ActiveCampaign
in the examples.
$ActiveCampaign = new ActiveCampaign("{{URL}}", "{{KEY}}");
use BalintHorvath\ActiveCampaign\ActiveCampaign;
Using inside a class under different access name:
use BalintHorvath\ActiveCampaign\ActiveCampaign as ActiveCampaignWrapper;
class ActiveCampaign
{
public function __construct(){
$ActiveCampaign = new ActiveCampaignWrapper("{{URL}}", "{{KEY}}");
}
}
In general, calls on resources look like this:
$ActiveCampaign->{Module}->{Resource}->{Method}($id, $properties);
For example:
$customerID = $ActiveCampaign->Ecommerce->Customer->get($id);
For example:
$ActiveCampaign = new ActiveCampaignWrapper("{{URL}}", "{{KEY}}");
$customerID = $ActiveCampaign->Ecommerce->Customer->get($id);
This package has included test cases for Kahlan.