Home

myquealer edited this page Sep 13, 2010 · 6 revisions
Clone this wiki locally

Usage

To use the classes, simply require src/streamsend.php in your code. Also, you must define two constants for your API Login ID and Key so that you can properly authenticate with the API:

require_once 'streamsend-php/src/streamsend.php';

define('STREAMSEND_USERNAME', 'abc'); // Login ID
define('STREAMSEND_PASSWORD', '123'); // Key

Resources

Every resource in StreamSend has a corresponding PHP class, e.g. lists are instances of SSList, blasts are instances of SSBlast, etc. Most resources have the same basic set of actions.

Find

To find one or more instances of a resource, use the find class method:

// find all emails
$emails = SSEmail::find('all')

// find a specific email
$email = SSEmail::find(1)

Note: The above code does not work. “Call to undefined method SSEmail::find()” and there’s no audience ID which now seems to be required.

Save (Create, Update)

To save a resource, simply call the save instance method. This automatically handles both creates and updates:

$email = new SSEmail(array('name' => 'My Email'));

// email is new, so it will be created
$email->save();

$email->attributes['name'] = 'Newsletter';

// email already exists, so it will be updated
$email->save();

Destroy

To destroy a resource, call the destroy instance method:

$email = SSEmail::find(1)

$email->destroy();