trycourier / courier-php

A PHP package for communicating with the Courier REST API.
https://packagist.org/packages/trycourier/courier
MIT License
11 stars 4 forks source link

Courier SDK

Courier PHP SDK supporting:

Official Courier API docs

For a full description of request and response payloads and properties, please see the official Courier API docs.

Requirements

Installation

This library uses HTTPlug as HTTP client. HTTPlug is an abstraction that allows this library to support different HTTP Clients. Therefore, you need to provide it with an client and/or adapter for the HTTP library you prefer. You can find all the available adapters in Packagist. This documentation assumes you use the Guzzle Client, but you can replace it with any client that you prefer.

The recommended way to install courier-php is through Composer:

composer require trycourier/courier guzzlehttp/guzzle

Configuration

Instantiate the Courier client class with your authorization token OR username and password. Providing just an authorization token will generate a "Bearer" authorization header, while providing a username and password will generate a "Basic" (base64-encoded) authorization header

$client = new CourierClient("base-url", "authorization-token", "username", "password");

Options

Many methods allow the passing of optional data to the Courier endpoints. This data should be an associative array of key/value pairs. The exact options supported are dependent on the endpoint being called. Please refer to the official Courier documentation for more information.

$profile = [
    "firstname" => "Johnny",
    "lastname" => "Appleseed",
    "email" => "courier.pigeon@mail.com"
];

Methods

For a full description of request and response payloads and properties, please see the official Courier API docs.

Send API

Messages API

Lists API

Brands API

Events API

Profiles API

Preferences API

Notifications API

Automations API

Bulk API

Audiences API

Token Management API

Audit Events API

Accounts API (only on v1.12.0)

Tenants API (v2.0.0+)

Users API

Errors

All unsuccessful (non 2xx) responses will throw a CourierRequestException. The full response object is available via the getResponse() method.