1. Go to this page and download the library: Download xdubois/activecampaign-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xdubois / activecampaign-api example snippets
use xdubois\ActiveCampaign\ActiveCampaignAPI;
$api = new ActiveCampaignAPI('your-api-key', 'https://youraccount.api-us1.com');
use xdubois\ActiveCampaign\ActiveCampaignAPI;
use xdubois\ActiveCampaign\Configuration;
$config = new Configuration(
'your-api-key',
'https://youraccount.api-us1.com',
timeout: 60, // Total request timeout in seconds
connectTimeout: 10, // Connection timeout in seconds
maxRetries: 3, // Retries for 429 / 5xx / network errors
retryDelay: 1.0, // Base delay in seconds, doubled after each retry (Retry-After wins when present)
defaultHeaders: ['User-Agent' => 'my-app/1.0'],
);
$api = new ActiveCampaignAPI($config);
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
$mock = new MockHandler([new Response(200, [], '{"contact": {"id": "1"}}')]);
$client = new Client(['handler' => HandlerStack::create($mock)]);
$api = new ActiveCampaignAPI($config, null, $client);
$api->contacts()->get(1); // => ['contact' => ['id' => '1']]