/EmailOctopus

EmailOctopus API client for PHP

Primary LanguagePHPMIT LicenseMIT

EmailOctopus

Packagist GitHub license Travis branch Codacy branch

A PHP wrapper for EmailOctopus email marketing service.

For more information on how to set up your account, read the API docs.

Installation

To add the library in your project just type the following:

composer require ideneal/emailoctopus

Usage

First you need to retrieve the API key as explained in API docs. After that you could initialize the wrapper by adding the following code:

use Ideneal\EmailOctopus\EmailOctopus;

$emailOctopus = new EmailOctopus('YOUR-API-KEY');

Now you can perform the CRUD operations the API provides using the $emailOctopus instance.

Create new list

use Ideneal\EmailOctopus\Entity\MailingList;

$list = new MailingList();
$list->setName('My cool list');

$emailOctopus->createMailingList($list);

Add a contact to the previous list

use Ideneal\EmailOctopus\Entity\Contact;

$contact = new Contact();
$contact
    ->setEmail('john.doe@mail.com')
    ->setFirstName('John')
    ->setLastName('Doe')
;

$emailOctopus->createContact($contact, $list);

Retrieve all contacts from the previous list

$emailOctopus->getContactsByMailingList($list);

Remove contact from the previous list

$contact = $emailOctopus->getContactByMailingList('CONTACT-ID', $list);
$emailOctopus->deleteContact($contact, $list);

License

The repository is available as open source under the terms of the MIT License.