Giter Site home page Giter Site logo

erinmailphp's Introduction

ErinmailPHP

A PHP class built to interface with the erinmail API (http://erinmail.com)

Installation

Using Composer

Begin by installing this package through Composer. Edit your project's composer.json file to require mhamzas/erinmailphp.

"require": {
	"mhamzas/erinmailphp": "dev-master"
}

Next, update Composer from the Terminal:

composer update

Old School (alternative option)

  • Place ErinmailPHP.php into your file structure
  • Include or require ErinmailPHP in the location you would like to utilize it
	require('ErinmailPHP\ErinmailPHP.php');

#Usage

Create an instance of the class while passing in an array including your API key and the List ID you wish to work with.

	$config = array(
		'api_key' => 'yourapiKEYHERE', //your API key is available in Settings
		'list_id' => 'your_list_id_goes_here'
	);
	
	$erinmail = new erinmailPHP($config);
	
	//you can change the list_id you are referring to at any point
	$erinmail->setListId("a_different_list_id");

#Methods After creating a new instance of ErinmailPHP call any of the methods below

##Return Values The return value of any of these functions will include both a status, and a message to go with that status.

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

	//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.

##subscribe(array $values)

This method takes an array of $values and will attempt to add the $values into the list specified in $list_id

	$results = $erinmail->subscribe(array(
						'name'=>'Jim',
						'email' => '[email protected]', //this is the only field required by erinmail
						'customfield1' => 'customValue'
						));

Note: Be sure to add any custom fields to the list in erinmail 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.

##unsubscribe($email)

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

	$results = $erinmail->unsubscribe('[email protected]');

##substatus($email)

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

	$results = $erinmail->substatus('[email protected]');

Note: refer to the code or see http://erinmail.com/api for the types of return messages you can expect.

##subcount()

Returns the number of subscribers to the current list.

	$results = $erinmail->subcount();

##setListId($list_id) and getListId()

Change or get the list you are currently working with.

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

#Unit tests All unit tests are located under src/test directory. To run the tests type in the below from the project root.

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

Ensure that the API keys are setup for testing :

		$config = [
			'api_key' => 'xxx', //your API key is available in Settings
			'list_id' => 'xxx'// List ID
		];

erinmailphp's People

Watchers

James Cloos avatar M Hamza Siddiqui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.