smart-sender/php-sdk

PHP library for the Smart Sender API.

v1.0.1 2023-06-01 19:30 UTC

This package is auto-updated.

Last update: 2025-03-29 01:06:57 UTC


README

License

The Smart Sender PHP library provides convenient access to the Smart Sender API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Smart Sender API.

Requirements

PHP 7.4 and later.

Composer

You can install the bindings via Composer. Run the following command:

composer require smart-sender/php-sdk

To use the bindings, use Composer's autoload:

require_once 'vendor/autoload.php';

Dependencies

The bindings require the following extensions in order to work properly:

The bindings require the following packages in order to work properly:

Getting started

Supported services:

Simple usage looks like:

$manager = \SmartSender\Manager::withToken('uwWH632A3w47mK80iiC94yiMgGOfw3QNGIdjmnAX5eXqvgNkWGEKdaZQsQCJ');

$response = $manager->console->tags->create([
    'name' => 'Tag 1',
    'color' => '000000',
]);

$tag = $response->getTag();

echo $tag->id;
echo $tag->name;

Documentation

See the PHP API docs.

Configuration

Managing variables

Note Use Base URI setting only if the Smart Sender API URI has changed or you are using a shim on your server that is similar to the Smart Sender API.

// setup proxy url
putenv('SMART_SENDER_BASE_URI=https://proxy.com');

// setup access token
putenv('SMART_SENDER_ACCESS_TOKEN=test');

// setup proxy url
putenv('SMART_SENDER_VERSION=v2.2');

Default manager

Note Change the access token before calling the Smart Sender API methods. By default, a non-existent token is specified in the config, calls with which will give an error.

// use the Smart Sender API client from default settings
$manager = \SmartSender\Manager::default();

// retrieve value from SMART_SENDER_ACCESS_TOKEN environment variable.
echo $manager->client->getAccessToken();