2017 © Pedro Peláez
 

library sendyphp

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

image

jacobbennett/sendyphp

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  • Monday, April 17, 2017
  • by JacobBennett
  • Repository
  • 19 Watchers
  • 118 Stars
  • 39,054 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 34 Forks
  • 3 Open issues
  • 6 Versions
  • 13 % Grown

The README.md

SendyPHP

Latest Version on Packagist Total Downloads, (*1)

A PHP class built to interface with the Sendy API (http://sendy.co), (*2)

Installation

Using Composer

Begin by installing this package through Composer. Edit your project's composer.json file to require jacobbennett/sendyphp., (*3)

"require": {
    "jacobbennett/sendyphp": "1.3.*"
}

Next, update Composer from the Terminal:, (*4)

composer update

Non-Composer Installation

  • Grab the src/SendyPHP.phpfile and place it into your file structure.
  • Require SendyPHP in the location you would like to utilize it.
    require('SendyPHP.php');

Usage

Create an instance of the class while passing in an array including your API key, installation URL, and the List ID you wish to work with., (*5)


$config = array( 'api_key' => 'yourapiKEYHERE', //your API key is available in Settings 'installation_url' => 'http://updates.mydomain.com', //Your Sendy installation 'list_id' => 'your_list_id_goes_here' ); $sendy = new \SendyPHP\SendyPHP($config); //you can change the list_id you are referring to at any point $sendy->setListId("a_different_list_id");

Methods

After creating a new instance of SendyPHP call any of the methods below, (*6)

Return Values

The return value of any of these functions will include both a status, and a message to go with that status., (*7)

The status is a boolean value of true or false and the message will vary based on the type of action being performed., (*8)

    //example of a succesful return value
    array(
        'status'=>true,
        'message'=>'Already Subscribed'
    )

    //example of a UNsuccesful return value
    array(
        'status'=>false,
        'message'=>'Some fields are missing.'
    )

I have commented and organized the code so as to be readable, if you have further questions on the status or messages being returned, please refer to the library comments., (*9)

subscribe(array $values)

This method takes an array of $values and will attempt to add the $values into the list specified in $list_id, (*10)

    $results = $sendy->subscribe(array(
        'name'=>'Jim',
        'email' => 'Jim@gmail.com', //this is the only field required by sendy
        'customfield1' => 'customValue'
    ));

Note: Be sure to add any custom fields to the list in Sendy before utilizing them inside this library. Another Note: If a user is already subscribed to the list, the library will return a status of true. Feel free to edit the code to meet your needs., (*11)

unsubscribe($email)

Unsubscribes the provided e-mail address (if it exists) from the current list., (*12)

    $results = $sendy->unsubscribe('test@testing.com');

substatus($email)

Returns the status of the user with the provided e-mail address (if it exists) in the current list., (*13)

    $results = $sendy->substatus('test@testing.com');

Note: refer to the code or see http://sendy.co/api for the types of return messages you can expect., (*14)

subcount()

Returns the number of subscribers to the current list., (*15)

    $results = $sendy->subcount();

createCampaign(array $values)

This method takes an array of $values and will creates a campaign (with an option to send it too)., (*16)

    $results = $sendy->createCampaign(array(
        'from_name' => 'Some Name',
        'from_email' => 'some@domain.com',
        'reply_to' => 'some@domain.com',
        'subject' => 'Some Subject',
        'plain_text' => 'Amazing campaign', // (optional).
        'html_text' => '<h1>Amazing campaign</h1>',
        'list_ids' => 'your_list_id', // Required only if you set send_campaign to 1.
        'brand_id' => 0, // Required only if you are creating a 'Draft' campaign.
        'query_string' => 'some', // eg. Google Analytics tags.
        'send_campaign' => 0 // Set to 1 if you want to send the campaign as well and not just create a draft. Default is 0.
    ));

setListId($list_id) and getListId()

Change or get the list you are currently working with., (*17)


//set or switch the list id $sendy->setListId('another_list_id'); //get the current list id echo $sendy->getListId();

Unit tests

All unit tests are located under src/test directory. To run the tests type in the below from the project root., (*18)

        php vendor/bin/phpunit src/test/SendyPHPTest.php

Ensure that the API keys are setup for testing :, (*19)


$config = [ 'api_key' => 'xxx', //your API key is available in Settings 'installation_url' => 'http://my.sendy.installation.com', //Your Sendy installation 'list_id' => 'xxx'// List ID ];

The Versions

17/04 2017

dev-master

9999999-dev

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

newsletter sendy

10/03 2016

v1.3

1.3.0.0

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

newsletter sendy

25/03 2015

v1.2.1

1.2.1.0

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

newsletter sendy

08/05 2014

v1.2

1.2.0.0

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

newsletter sendy

11/03 2014

1.1

1.1.0.0

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

newsletter sendy

15/02 2014

v1.0

1.0.0.0

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

  Sources   Download

The Requires

  • php >=5.3.0

 

newsletter sendy