### Install laravel-activecampaign via Composer Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-activecampaign ``` -------------------------------- ### Handle ActiveCampaignException Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Error handling example: catches ActiveCampaignException on non-2xx responses and logs the message with the decoded error body. ```php use JeffersonGoncalves\ActiveCampaign\Exceptions\ActiveCampaignException; try { ActiveCampaign::contacts()->get(999999); } catch (ActiveCampaignException $e) { logger()->error($e->getMessage(), $e->errorBody()); } ``` -------------------------------- ### Campaigns, Automations, Pipelines, Webhooks, and Users Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Operations for campaigns, automations, pipelines, webhooks, and users. Includes listing, getting, adding a contact to an automation, creating a webhook, and retrieving the current user. ```php ActiveCampaign::campaigns()->list(); ActiveCampaign::campaigns()->get(1); ActiveCampaign::automations()->list(); ActiveCampaign::automations()->addContact(automationId: 1, contactId: 42); ActiveCampaign::pipelines()->list(); ActiveCampaign::webhooks()->create( name: 'CRM Sync', url: 'https://example.com/hooks/activecampaign', events: ['subscribe', 'unsubscribe'], ); ActiveCampaign::users()->me(); ActiveCampaign::users()->list(); ``` -------------------------------- ### Contact operations with ActiveCampaign Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Contact operations: list with filters, get by ID, create, update, delete, and sync (upsert by email). ```php use JeffersonGoncalves\ActiveCampaign\Facades\ActiveCampaign; // List (supports email, search, listid, status, limit, offset filters) $contacts = ActiveCampaign::contacts()->list(['email' => 'jane@example.com']); $contact = ActiveCampaign::contacts()->get(1); $contact = ActiveCampaign::contacts()->create([ 'email' => 'jane@example.com', 'firstName' => 'Jane', 'lastName' => 'Doe', ]); ActiveCampaign::contacts()->update(1, ['firstName' => 'Janet']); ActiveCampaign::contacts()->delete(1); // Upsert by email ActiveCampaign::contacts()->sync(['email' => 'jane@example.com', 'firstName' => 'Jane']); ``` -------------------------------- ### Publish activecampaign-config Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Publish the package configuration file. ```bash php artisan vendor:publish --tag=activecampaign-config ``` -------------------------------- ### ActiveCampaign configuration file Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Configuration file for the package. It reads the API URL, API key, and default limit from environment variables. ```php // config/activecampaign.php return [ 'api_url' => env('ACTIVECAMPAIGN_API_URL', ''), 'api_key' => env('ACTIVECAMPAIGN_API_KEY', ''), 'default_limit' => env('ACTIVECAMPAIGN_DEFAULT_LIMIT', 20), ]; ``` -------------------------------- ### Run the test suite with composer test Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Use this command to run the package's test suite. It is the standard way to execute tests for this Laravel package. ```bash composer test ``` -------------------------------- ### Set ActiveCampaign credentials in .env Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Set ActiveCampaign credentials in the .env file. Both values are found under Settings > Developer in your ActiveCampaign account. ```env ACTIVECAMPAIGN_API_URL=https://youraccountname.api-us1.com ACTIVECAMPAIGN_API_KEY=your-api-key ``` -------------------------------- ### List operations with ActiveCampaign Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md List operations: list all, create, subscribe/unsubscribe a contact, and delete. ```php $lists = ActiveCampaign::lists()->list(); $list = ActiveCampaign::lists()->create(['name' => 'Newsletter']); ActiveCampaign::lists()->subscribe(listId: 1, contactId: 42); ActiveCampaign::lists()->unsubscribe(listId: 1, contactId: 42); ActiveCampaign::lists()->delete(1); ``` -------------------------------- ### Deal operations with ActiveCampaign Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Deal (CRM) operations: list with filters, create with value in cents and pipeline/stage, update, and delete. ```php $deals = ActiveCampaign::deals()->list(['search' => 'Big Sale', 'stage' => 3]); $deal = ActiveCampaign::deals()->create([ 'title' => 'Big Sale', 'value' => 10000, // in cents 'currency' => 'usd', 'group' => 1, // pipeline id 'stage' => 3, 'contact' => 42, ]); ActiveCampaign::deals()->update($deal['deal']['id'], ['stage' => 5]); ActiveCampaign::deals()->delete($deal['deal']['id']); ``` -------------------------------- ### Tag operations with ActiveCampaign Source: https://github.com/jeffersongoncalves/laravel-activecampaign/blob/main/README.md Tag operations: list with search, create, add/remove on a contact, and delete. ```php $tags = ActiveCampaign::tags()->list(['search' => 'vip']); $tag = ActiveCampaign::tags()->create('vip'); ActiveCampaign::tags()->addToContact(tagId: $tag['tag']['id'], contactId: 42); ActiveCampaign::tags()->removeFromContact($contactTagId); ActiveCampaign::tags()->delete($tag['tag']['id']); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.