PHP code example of label84 / laravel-active-campaign

1. Go to this page and download the library: Download label84/laravel-active-campaign 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/ */

    

label84 / laravel-active-campaign example snippets


use Label84\ActiveCampaign\Facades\ActiveCampaign;

// Usage
$contact = ActiveCampaign::contacts()->get(1);

use Label84\ActiveCampaign\ActiveCampaign;

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

use Label84\ActiveCampaign\ActiveCampaign;

class ContactController extends Controller
{
    public function __construct(private readonly ActiveCampaign $activeCampaign) { }

    // Usage
    $this->activeCampaign->contacts()->get(1);
}

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

$contacts = ActiveCampaign::contacts()->list();
$contactByEmail = ActiveCampaign::contacts()->list('[email protected]');
$singleList = ActiveCampaign::contacts()->list('listid=1');

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

$contact = ActiveCampaign::contacts()->sync('[email protected]', [
    'firstName' => 'John',
    'lastName' => 'Doe',
    'phone' => '+3112345678',
]);

use Label84\ActiveCampaign\DataObjects\ActiveCampaignContact;

$contact = new ActiveCampaignContact(
    id: 1,
    email: '[email protected]',
    phone: '+3112345678',
    firstName: 'John',
    lastName: 'Deer',
);

ActiveCampaign::contacts()->update($contact);

$contact = ActiveCampaign::contacts()->updateListStatus(
    contactId: 1,
    listId: 1,
    status: 1,
);

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

$contactTagId = ActiveCampaign::contacts()->tag(
    id: 1,
    tagId: 20
);

ActiveCampaign::contacts()->untag(contactTagId: 2340);

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

$fieldValueId = ActiveCampaign::fieldValues()->create(
    contactId: 1,
    fieldId: 50,
    value: 'active',
);

use Label84\ActiveCampaign\DataObjects\ActiveCampaignFieldValue;

$fieldValue = new ActiveCampaignFieldValue(
    contactId: 1,
    field: 50,
    value: 'inactive',
);

ActiveCampaign::fieldValues()->update($fieldValue);

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

$field = ActiveCampaign::fields()->get(1);

$fieldId = ActiveCampaign::fields()->create(
    type: 'textarea',
    title: 'about',
    description: 'Short introduction',
);

use Label84\ActiveCampaign\DataObjects\ActiveCampaignField;

$fieldValue = new ActiveCampaignField(
    id: 1,
    type: 'textarea',
    title: 'about',
    description: 'Relevant skills',
);

ActiveCampaign::fields()->update($fieldValue);

ActiveCampaign::fields()->delete(1);

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

$tags = ActiveCampaign::tags()->list();
$filteredTags = ActiveCampaign::tags()->list('test_');

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

use Label84\ActiveCampaign\DataObjects\ActiveCampaignTag;

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

ActiveCampaign::tags()->update($tag);

ActiveCampaign::tags()->delete(100);
sh
php artisan vendor:publish --provider="Label84\ActiveCampaign\ActiveCampaignServiceProvider" --tag="config"