2017 © Pedro PelĂĄez
 

library php-sdk

The Mailmatics PHP SDK

image

mailmatics/php-sdk

The Mailmatics PHP SDK

  • Tuesday, September 13, 2016
  • by metaline
  • Repository
  • 3 Watchers
  • 0 Stars
  • 54 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP Mailmatics SDK

A PHP client for the Mailmatics API., (*1)

This library is in development. Use it at your risk., (*2)

Requirements

Installation

The recommended way to install PHP Mailmatics SDK is through Composer., (*3)

$ curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version:, (*4)

$ php composer.phar require mailmatics/php-sdk

After installing, you need to require the Composer’s autoloader:, (*5)

require 'vendor/autoload.php';

Authentication

PHP Mailmatics SDK supports two authentication modes:, (*6)

1. API key:, (*7)

use Mailmatics\Client;

$client = new Client(['apiKey' => '...']);

2. Simple login:, (*8)

use Mailmatics\Client;

$client = new Client(['username' => 'admin', 'password' => '12345']);

Options

TODO, (*9)

HTTP Client

Internally, PHP Mailmatics SDK uses an implementation of Mailmatics\HttpClientInterface. The default is Mailmatics\HttpClient\StreamClient. You can change it by passing it to the client constructor:, (*10)

use Mailmatics\Client;
use Mailmatics\HttpClient\CurlClient;

$client = new Client($credentials, $options, new CurlClient());

The more powerful implementation is the Mailmatics\HttpClient\GuzzleHttpClient, that require the Guzzle library., (*11)

use Mailmatics\HttpClient\GuzzleHttpClient;

$httpClient = new GuzzleHttpClient();

You can pass your instance of Guzzle client in the constructor:, (*12)

use GuzzleHttp\Client as GuzzleClient;
use Mailmatics\HttpClient\GuzzleHttpClient;

$guzzleClient = new GuzzleClient();
$httpClient = new GuzzleHttpClient($guzzleClient);

Lists

Get all lists:, (*13)

$lists = $client->getLists()->all();

Get a single list:, (*14)

$list = $client->getLists()->get(123);

Subscribe a user to a list

$list = $client->getLists()->addSubscriber($listId, $email);

You can specify also first and last name:, (*15)

$data = [
    'firstname' => 'John',
    'lastname' => 'Smith',
];

$list = $client->getLists()->addSubscriber(123, $email, $data);

...or the fullname (Mailmatics automagicaly split first and last name):, (*16)

$data = [
    'fullname' => 'John Smith',
];

$list = $client->getLists()->addSubscriber(123, $email, $data);

Unsubscribe a user

To unsubscribe a user from a list, you must have his subscriber ID., (*17)

$list = $client->getLists()->unsubscribe($listId, $subscriberId);

TODO: How can I obtain the subscriber ID?, (*18)

Transactional Emails

Get all transactional emails:, (*19)

$emails = $client->getTransactional()->all();

Get a single transactional email:, (*20)

$email = $client->getTransactional()->get(123);

Send a transactional email:, (*21)

$data = [
    'firstName' => 'John',
    'lastName' => 'Smith'
];

$email = $client->getTransactional()->send(123, 'john@example.com', $data);

Send a scheduled transactional email:, (*22)

$data = [
    'firstName' => 'John',
    'lastName' => 'Smith'
];

$schedule = new DateTime('2018-12-25 12:30:00');

$email = $client->getTransactional()->send(123, 'john@example.com', $data, $schedule);

License

This library is licensed under the MIT License - see the LICENSE file for details., (*23)

The Versions

13/09 2016

dev-master

9999999-dev https://github.com/metaline/mailmatics-sdk-php

The Mailmatics PHP SDK

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniele De Nobili

newsletter sdk mailmatics