Jozsef Hocza

Sendy API for Laravel

Sendy Check it out at Github

sendy-laravel

A service provider for Sendy API in Laravel 5

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

composer require hocza/sendy:1.*

or append your composer.json with:

"require": {
	"hocza/sendy": "1.*"
},

Add the following settings to the config/app.php

Service provider:

'providers' => [
	...
	'Hocza\Sendy\SendyServiceProvider',
]

For the Sendy:: facade

'aliases' => [
	...
	'Sendy' => 'Hocza\Sendy\Facades\Sendy',
]

Configuration

php artisan vendor:publish --provider="Hocza\Sendy\SendyServiceProvider"

It will create sendy.php within the config directory.

<?php
return [
    'listId' => '',
    'installationUrl' => '',
    'apiKey' => '',
];

Usage

###Subscribe:

$data = [
	'email' => 'johndoe@example.com',
	'name' => 'John Doe',
	'any_custom_column' => 'value'
];
Sendy::subscribe($data);

RESPONSE (array)

In case of success:

['status' => true, 'message' => 'Subscribed']
['status' => true, 'message' => 'Already subscribed']

In case of error:

['status' => false, 'message' => 'The error message']

###Unsubscribe:

$email = 'johndoe@example.com';
Sendy::unsubscribe($email);

RESPONSE (array)

In case of success:

['status' => true, 'message' => 'Unsubscribed']

In case of error:

['status' => false, 'message' => 'The error message']

###Subscription status

$email = 'johndoe@example.com';
Sendy::status($email);

RESPONSE (Plain text)

Success: Subscribed

Success: Unsubscribed

Success: Unconfirmed

Success: Bounced

Success: Soft bounced

Success: Complained

Error: No data passed

Error: API key not passed

Error: Invalid API key

Error: Email not passed

Error: List ID not passed

Error: Email does not exist in list

###Active subscriber count

Sendy::count();
#To check other list:
Sendy::setListId($list_id)->count();

RESPONSE (Plain text)

Success: You'll get an integer of the active subscriber count

Error: No data passed

Error: API key not passed

Error: Invalid API key

Error: List ID not passed

Error: List does not exist

###Create campaign

Sendy::createCampaign($campaignOptions, $campaignContent);

###Change list ID

To change the default list ID simply prepend with setListId($list_id)
Examples:
Sendy::setListId($list_id)->subscribe($data);
Sendy::setListId($list_id)->unsubscribe($email);
Sendy::setListId($list_id)->status($email);
Sendy::setListId($list_id)->count();

Todo

Buy me a coffee :)

Click here to lend your support to: Sendy-laravel and make a donation at pledgie.com !

SUBSCRIBE
Subscribe to my e-mail list.
You can unsubscribe anytime.