Coder Social home page Coder Social logo

laravel-active-campaign's Introduction

Laravel ActiveCampaign

Latest Stable Version MIT Licensed Quality Score Total Downloads

This package provides a simple interface to the ActiveCampaign API v3.

Currently the packages only supports the endpoints Contacts, Custom Fields Values and Tags. Feel free to PR the remaining endpoints.

Requirements

  • PHP 8.x
  • Laravel 9.x

Installation

1. Install the package via composer

composer require label84/laravel-active-campaign

2. Publish the config file

php artisan vendor:publish --provider="Label84\ActiveCampaign\ActiveCampaignServiceProvider" --tag="config"

3. Add the base URL and API key to your .env

ACTIVE_CAMPAIGN_BASE_URL=
ACTIVE_CAMPAIGN_API_KEY=

Usage

Contacts

Retreive an existing contact by their id

use Label84\ActiveCampaign\ActiveCampaign;

$contact = resolve(ActiveCampaign::class)->contacts()->get(1);

List all contact, search contacts, or filter contacts by query defined criteria

use Label84\ActiveCampaign\ActiveCampaign;

$contacts = resolve(ActiveCampaign::class)->contacts()->list('[email protected]');

Create a contact and get the contact id

use Label84\ActiveCampaign\ActiveCampaign;

$contactId = resolve(ActiveCampaign::class)->contacts()->create('[email protected]', [
    'firstName' => 'John',
    'lastName' => 'Doe',
    'phone' => '+3112345678',
]);

Update an existing contact

use Label84\ActiveCampaign\ActiveCampaign;
use Label84\ActiveCampaign\DataObjects\ActiveCampaignContact;

$contact = new ActiveCampaignContact(1, '[email protected]', '+3112345678', 'John', 'Deer');

$contact = resolve(ActiveCampaign::class)->contacts()->update($contact);

Delete an existing contact by their id

use Label84\ActiveCampaign\ActiveCampaign;

resolve(ActiveCampaign::class)->contacts()->delete(1);

Add a tag to contact

use Label84\ActiveCampaign\ActiveCampaign;

resolve(ActiveCampaign::class)->contacts()->tag(1, 20);

Remove a tag from a contact

use Label84\ActiveCampaign\ActiveCampaign;

resolve(ActiveCampaign::class)->contacts()->untag(2340);

Custom Field Values

Retreive an existing field value by their id

use Label84\ActiveCampaign\ActiveCampaign;

$fieldValue = resolve(ActiveCampaign::class)->fieldValues()->get(50);

Create a field value and get the id

use Label84\ActiveCampaign\ActiveCampaign;

$fieldValue = resolve(ActiveCampaign::class)->fieldValues()->create(1, 50, 'active');

Update an existing field value

use Label84\ActiveCampaign\ActiveCampaign;
use Label84\ActiveCampaign\DataObjects\ActiveCampaignFieldValue;

$fieldValue = new ActiveCampaignFieldValue(1, 50, 'inactive');

$fieldValue = resolve(ActiveCampaign::class)->fieldValues()->update($fieldValue);

Delete an existing field value by their id

use Label84\ActiveCampaign\ActiveCampaign;

resolve(ActiveCampaign::class)->fieldValues()->delete(50);

Tags

Retreive an existing tag by their id

use Label84\ActiveCampaign\ActiveCampaign;

$tag = resolve(ActiveCampaign::class)->tags()->get(100);

List all tags filtered by name

use Label84\ActiveCampaign\ActiveCampaign;

$tags = resolve(ActiveCampaign::class)->tags()->list('abc');

Create a tag and get the id

use Label84\ActiveCampaign\ActiveCampaign;

$tag = resolve(ActiveCampaign::class)->tags()->create('test_tag', 'This is a new tag');

Update an existing tag

use Label84\ActiveCampaign\ActiveCampaign;
use Label84\ActiveCampaign\DataObjects\ActiveCampaignTag;

$tag = new ActiveCampaignTag(100, 'test_tag', 'Another description');

$tag = resolve(ActiveCampaign::class)->tags()->update($tag);

Delete an existing tag by their id

use Label84\ActiveCampaign\ActiveCampaign;

resolve(ActiveCampaign::class)->tags()->delete(100);

Tests

./vendor/bin/phpstan analyse

License

MIT

laravel-active-campaign's People

Contributors

trippo avatar tjardoo avatar jakoffe avatar

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.