reneeshkuttan/whitemail-api

This package provides a wrapper for Whitemail Api

1.0.0 2016-11-28 05:14 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:24:43 UTC


README

WhitemailApi is a PHP wrapper to whitemail api.

Contents

Installation

  1. In order to install WhitemailApi, just add the following to your composer.json. Then run composer update:
"reneeshkuttan/whitemail-api": "1.0.x-dev"

Usage

Requirements

Before you start, acquire your API End Point url and API Key from whitemail's company settings page.

Initializtion

Let's start by creating a new instance of WhitemailApi:

$api = new WhitemailApi($apiEndPoint, $apiKey);

Identify

Now we can send a call through the API to identify a subscriber

$subscriberData = [
	'email'  => "johns@example.com",
            'fields' => [
                'first_name' => 'John',
                'last_name' => 'Sam'
             ]
];

$api->identify($subscriberData);

On succesful request, the identify function would return an associative array with the details of the subscriber:

Array ( [success] => 1 [message] => Subscriber succesfully created/updated [subscriber] => Array ( [id] => 31 [uris] => Array ( [show] => http://client1.whitemail5.dev/subscriber/31 ) ) ) 

Track

Use the track() function to track subscriber events:

$trackData = [
            'email' => 'johns@example.com',
            'eventName' => 'purchased',
            'data' => ['amt' => '40.50'],
        ];

$api->track($trackData);

On success this would return an associative array with status information

Array ( [success] => 1 [message] => Subscriber event added ) 

License

WhitemailApi is free software distributed under the terms of the MIT license.