2017 © Pedro Peláez
 

library rest-api

A php library which implements the functionality of FreshMail REST API.

image

freshmail/rest-api

A php library which implements the functionality of FreshMail REST API.

  • Monday, October 23, 2017
  • by FreshMail
  • Repository
  • 4 Watchers
  • 9 Stars
  • 5,183 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 4 Versions
  • 55 % Grown

The README.md

FreshMail

A php library which implements connection to FreshMail REST API., (*1)

This API client covers all functions of API V2 such as: - subscribers management - list management - campaign management - sending transactional SMS messages, (*2)

If You want to send transactional messages in rich format please use new API V3 client., (*3)

Installation via composer (compatible with PHP >=8.0)

Add via composer:, (*4)

composer require freshmail/rest-api:^4.0

Installation via composer (compatible with PHP >=7.0)

Add via composer:, (*5)

composer require freshmail/rest-api:^3.0

Installation of old version of library (compatible with PHP >=5.3)

Add via composer:, (*6)

composer require freshmail/rest-api:^2.0

Usage

Below some simple examples, for whole API function see full API V2 doc, (*7)

Test connection

use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$apiClient->doRequest('ping');

Create subscribers list

use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$data = [
    'name' => 'List with subscribers from my website'
];

$apiClient->doRequest('subscribers_list/create', $data);

Add subscriber to list

use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$data = [
    'email' => 'example@email.address',
    'list' => 'list_hash'
];

$apiClient->doRequest('subscriber/add', $data);

Get file from async api

use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$data = [
    'id_job' => 'XXX'
];

$zipContent = $apiClient->doFileRequest('async_result/getFile', $data);

file_put_contents('/testLocation/testfile.zip', $zipContent);

Proxy setup

To use proxy You can pass Your own GuzzleHttp Client:, (*8)

use \FreshMail\ApiV2\Client;

$guzzleClient = new \GuzzleHttp\Client(
    [
        'proxy' => 'my proxy url'
    ]
);

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);
$apiClient->setGuzzleHttpClient($guzzleClient);

Debugging

PSR-3 Logger Interface

You can use any library that implements PSR-3 Psr\Log\LoggerInterface, example with Monolog below:, (*9)

use \FreshMail\ApiV2\Client;  

$logger = new \Monolog\Logger('myCustomLogger');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stderr', \Monolog\Logger::DEBUG));

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);
$apiClient->setLogger($monolog);

Using Guzzle

You can also pass Your own GuzzleHttp Client with proper configuration:, (*10)

use \FreshMail\ApiV2\Client;

$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(
    \GuzzleHttp\Middleware::log(
        new \Monolog\Logger('Logger'),
        new \GuzzleHttp\MessageFormatter(\GuzzleHttp\MessageFormatter::DEBUG)
    )
);

$guzzleClient = new \GuzzleHttp\Client(
    [
        'handler' => $stack,
    ]
);

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);
$apiClient->setGuzzleHttpClient($guzzleClient);

The Versions

23/10 2017

dev-master

9999999-dev

A php library which implements the functionality of FreshMail REST API.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

rest freshmail

23/10 2017

v2.0.1

2.0.1.0

A php library which implements the functionality of FreshMail REST API.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

rest freshmail

19/02 2017

v2.0

2.0.0.0

A php library which implements the functionality of FreshMail REST API.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

rest freshmail

15/09 2016

v1.0

1.0.0.0

REST API

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0