Git Product home page Git Product logo

activecampaign-sdk's Introduction

ActiveCampaign API SDK

Tests status Coverage Status

This library is a simple PHP wrapper for the ActiveCampaign API v3.

Installation

Install the latest version with Composer:

composer require metaline/activecampaign-sdk

Requirements

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.

Documentation

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');

Or create a new contact:

$result = $client->post('contacts', [
    'contact' => [
        'email'     => '[email protected]',
        'firstName' => 'John',
        'lastName'  => 'Doe',
        'phone'     => '7223224241',
    ]
]);

Or delete an existing one:

$result = $client->delete('contacts/' . $contactId);

And so on.

Check the ActiveCampaign documentation for the other APIs.

Work with the Result object

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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

activecampaign-sdk's People

Contributors

omoikane avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

activecampaign-sdk's Issues

Supporto a Guzzle 7

Aggiungere Guzzle 7 nel composer.json e verificare che la libreria funzioni correttamente.

Some endpoint returns a 404 response with a message not handled by the error handling

Some endpoint returns a 404 response with a message not handled by the error handling of this SDK. For example:

$result = $client->put('contacts/18', $data);
$successful = $result->isSuccessful(); // false
$errors = $result->getErrors(); // empty array

But the internal response is like this:

HTTP/1.1 404 Not Found

{"message":"No Result found for Subscriber with id 18"}

We can improve the error handling and take the value of the message parameter (if it exists).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.