balint-horvath / activecampaign-php

(Under Developement) ActiveCampaign PHP Wrapper (PHP 7+, ActiveCampaign API v3+)
Apache License 2.0
1 stars 0 forks source link
activecampaign api api-client api-wrapper apis php-api php-client php-library php-sdk php-wrapper php7 sdk wrapper

ActiveCampaign PHP Wrapper (under development)

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.

API Wrapper Logic

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.)

dealsDeals / 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.)

ecomCustomersEcommerce / Customers

Credentials

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

Installation

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

via Composer

composer require balint-horvath/activecampaign-php

Phar

php composer.phar require balint-horvath/activecampaign-php

Basic Usage

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;

Instance

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}}");

Usage

use BalintHorvath\ActiveCampaign\ActiveCampaign;

Aliasing

Using inside a class under different access name:

use BalintHorvath\ActiveCampaign\ActiveCampaign as ActiveCampaignWrapper;

class ActiveCampaign
{

    public function __construct(){
        $ActiveCampaign = new ActiveCampaignWrapper("{{URL}}", "{{KEY}}");
    }

}

Using Modules

In general, calls on resources look like this:

$ActiveCampaign->{Module}->{Resource}->{Method}($id, $properties);

For example:

$customerID = $ActiveCampaign->Ecommerce->Customer->get($id);

Complete Example

For example:

$ActiveCampaign = new ActiveCampaignWrapper("{{URL}}", "{{KEY}}");
$customerID = $ActiveCampaign->Ecommerce->Customer->get($id);

Dependencies

Developer Dependencies

Unit & BDD Test

This package has included test cases for Kahlan.

PSR

PSR-4 Autoload