2017 © Pedro Peláez
 

library mautic-api-helper

image

barnebys/mautic-api-helper

  • Thursday, March 15, 2018
  • by barnebys
  • Repository
  • 2 Watchers
  • 2 Stars
  • 113 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 53 % Grown

The README.md

Mautic API Helper

Requires the Mautic Simple Mail plugin to be installed., (*1)

With basic auth

BarnebysMautic\Auth::initializeHttpBasic('username', 'password');
BarnebysMautic\Api::setBaseUrl('https://my.mautic.domain/api');

With oauth

BarnebysMautic\Auth::initializeOAuth2

Fetch a contact id by email

try {
    $data = BarnebysMautic\Api::getContactIdByMail('some@email.com');
} catch (BarnebysMautic\Exception\ContactNotFoundException $exception) {
    // Handle error
}

Handling Contacts

Creating a contact
BarnebysMautic\Api::createContact($email, array $fields = [);
Updating a contact

Updating a contact will do a PATCH and only update specified fields in the array., (*2)

BarnebysMautic\Api::updateContact($email, array $fields = [);

Sending emails

When sending emails you can with ease use sendToContact and just set the email and a templateId. If you need to pass on some custom fields to be used in Mautic those can set as a key => value array for parameter 3. When sending values contain HTML and to disable Mautic HTML escaper set the 4th parameter to true., (*3)

Sending a email with custom fields
$tokens = [
    'custom_content' => 'This will value will be available in mautic as {custom_content}'
];

sendToContact($mail, $templateId, $tokens)
Sending a email with html content
$tokens = [
    'html_content' => '<span>This html content will not be escpaed</span>'
];

sendToContact($mail, $templateId, $tokens, true)

Other available methods

getContactIdByMail($mail)
sendToLead($mail, $templateId, array $tokens = [], $html = false)
sendToContact($mail, $templateId, array $tokens = [], $html = false)

The Versions

15/03 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

15/03 2018

V0.4.0

0.4.0.0

  Sources   Download

MIT

The Requires

 

07/02 2018

V0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

18/01 2018

V0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

18/01 2018

v0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

 

17/01 2018

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

16/01 2018

v0.0.1

0.0.1.0

  Sources   Download

MIT

The Requires