2017 © Pedro Peláez
 

library dotmailer-api-v2-client

Client library for the dotMailer v2 (REST) API.

image

creativelittledots/dotmailer-api-v2-client

Client library for the dotMailer v2 (REST) API.

  • Tuesday, October 24, 2017
  • by terence1990
  • Repository
  • 1 Watchers
  • 0 Stars
  • 199 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 27 Forks
  • 0 Open issues
  • 24 Versions
  • 0 % Grown

The README.md

dotMailer API v2 PHP client

Latest Stable Version Total Downloads License Code Climate Codacy Badge, (*1)

(c) 2014-2016 Roman Piták, http://pitak.net roman@pitak.net, (*2)

PHP client library for the dotMailer v2 (REST) API with multiple accounts support!, (*3)

Full implementation according to the http://api.dotmailer.com/v2/help/wadl, (*4)

Type hinting support for objects and resources (not yet for arrays)., (*5)

Installation

The best way to install is to use the Composer dependency manager., (*6)

php composer.phar require romanpitak/dotmailer-api-v2-client

Usage

Single account usage

<?php
require_once('vendor/autoload.php');

$credentials = array(
    Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com',
    Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY'
);

$resources = Container::newResources($credentials);

echo $resources->GetAccountInfo();

Multiple accounts usage

<?php
require_once('vendor/autoload.php');

$credentials = array(
    'master' => array(
        Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com',
        Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY'
    ),
    'group1' => array(
        'g1-account1' => array(
            Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com',
            Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY'
        ),
        'g1-account2' => array(
            Container::USERNAME => 'apiuser-XXXXXXXXXXXX@apiconnector.com',
            Container::PASSWORD => 'YYYYYYYYYYYYYYYYYYYYYYYYYYY'
        )
    )
);

$container = Container::newContainer($credentials);

echo $container->getResources('master')->GetSegments();

$dataField = new ApiDataField();
$dataField->name = 'MY_DATA_FIELD';
$dataField->type = ApiDataTypes::STRING;
$dataField->visibility = ApiDataFieldVisibility::HIDDEN;

foreach ($container->group1 as $resources) {
    try {
        $resources->PostDataFields($dataField);
        echo 'OK';
    } catch (Exception $e) {
        echo 'Already exists';
    }
}

Create campaign with images (real life example)

<?php
// find the correct custom from address
$customFromAddresses = $account->GetCustomFromAddresses();
$customFromAddress = null;
foreach ($customFromAddresses as $cfa) {
    if ('roman@pitak.net' == $cfa->email) {
        $customFromAddress = $cfa;
        break;
    }
}
if (is_null($customFromAddress)) {
    throw new \Exception('Custom from address not found in the account.');
}

// Create campaign to get campaign ID
// we need the campaign id later to create image folder
$campaign = new ApiCampaign();
$campaign->name = 'My API Campaign';
$campaign->subject = 'Api Works';
$campaign->fromName = "Roman Piták";
$campaign->fromAddress = $customFromAddress->toJson();
// empty content (must include unsubscribe links)
$campaign->htmlContent = '<a href="http://$unsub$">UNSUB</a>';
$campaign->plainTextContent = 'http://$unsub$';
// save campaign
$campaign = $account->PostCampaigns($campaign);

// Create image folder
$folder = new ApiImageFolder();
$folder->name = date('c') . ' cid=' . (string)$campaign->id;
$folder = $account->PostImageFolder(new XsInt(0), $folder);
$folderId = $folder->id;

// Upload images
foreach ($images as $baseName => $data) {
    $apiFileMedia = new ApiFileMedia();
    $apiFileMedia->fileName = pathinfo($data['file'], PATHINFO_FILENAME);
    $apiFileMedia->data = base64_encode(file_get_contents($data['file']));
    $apiImage = $account->PostImageFolderImages($folderId, $apiFileMedia);
    // set the dotMailer src for the images
    $images[$baseName]['src'] = (string)$apiImage->path;
}

// UPDATE CAMPAIGN
$campaign->id = $campaign->id->toJson();
// getIndexHtml returns the html of the email with the correct src attribute for the images
// it uses the $images array
$htmlContent = getIndexHtml($includeDirectory);
$campaign->htmlContent = $htmlContent;
$html2text = new Html2Text($htmlContent);
$campaign->plainTextContent = $html2text->get_text();
$account->UpdateCampaign($campaign);

The Versions

24/10 2017

dev-master

9999999-dev https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

30/08 2017

1.1.5

1.1.5.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

05/04 2017

dev-php7-fix

dev-php7-fix https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

05/04 2017

v1.1.4

1.1.4.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

02/07 2016

v1.1.3

1.1.3.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

26/10 2015

v1.1.2

1.1.2.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

25/10 2015

dev-devel/tests

dev-devel/tests https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

15/09 2015

v1.1.1

1.1.1.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

09/09 2015

v1.1.0

1.1.0.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

12/06 2015

v1.0.11

1.0.11.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

22/04 2015

v1.0.10

1.0.10.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

22/04 2015

v1.0.9

1.0.9.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

25/11 2014

v1.0.8

1.0.8.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

24/11 2014

v1.0.7

1.0.7.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

15/09 2014

v1.0.6

1.0.6.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

10/09 2014

v1.0.5

1.0.5.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

20/03 2014

v1.0.4

1.0.4.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

20/03 2014

v1.0.3

1.0.3.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

15/03 2014

v1.0.2

1.0.2.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

13/03 2014

v1.0.1

1.0.1.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

11/03 2014

v1.0

1.0.0.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

03/03 2014

v0.3

0.3.0.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

02/03 2014

v0.2

0.2.0.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2

02/03 2014

v0.1

0.1.0.0 https://github.com/romanpitak/dotMailer-API-v2-PHP-client

Client library for the dotMailer v2 (REST) API.

  Sources   Download

MIT

The Requires

 

api rest client v2 dotmailer version 2