PHP client library for the Dotmailer REST API (v2) described at https://developer.dotmailer.com/docs/
composer config repositories.repo-name vcs https://github.com/famous-smoke/dotmailer-php
composer require famous-smoke/dotmailer-php:v1.2.3
NOTE: I added a config namespace and the code expects to find in there a class named Settings. This class should contain at minimum the constant DEFAULT_URI set to your dotmailer endpoint.
The class can be copied from below:
<?php
namespace Dotmailer\Config;
class Settings
{
const DEFAULT_URI = 'https://api.dotmailer.com'; //replace with your endpoint base URI from dotdigital.
}
<?php
use Dotmailer\Adapter\GuzzleAdapter;
use Dotmailer\Dotmailer;
require 'vendor/autoload.php';
$adapter = GuzzleAdapter::fromCredentials('[email protected]', 'PASSWORD');
$dotmailer = new Dotmailer($adapter);
$addressBooks = $dotmailer->getAddressBooks();
print_r($addressBooks);
If you are using Symfony, you may choose to configure the service as follows, and then use throughout your application:
# app/config/services.yml
Dotmailer\Adapter:
factory: ['Dotmailer\Adapter\GuzzleAdapter', fromCredentials]
arguments: ['%dotmailer_username%', '%dotmailer_password%', '%dotmailer_uri%']
Dotmailer\Dotmailer:
arguments: ['@Dotmailer\Adapter']
Currently the following endpoints are covered:
- Address books
- Get address books
- Campaigns
- Get all campaigns
- Get campaign
- Contacts
- Create contact
- Delete contact
- Update contact
- Add contact to address book
- Delete contact from address book
- Get contact by email
- Get contact address books
- Get unsubscribed contacts since date
- Unsubscribe contact
- Resubscribe contact
- Contact data fields
- Create contact data field
- Delete contact data field
- Programs
- Get programs
- Create program enrolment
- Transactional email
- Send transactional email
- Send transactional email using a triggered campaign