Skip to content

Commit fea870e

Browse files
committed
Merge branch 'release/1'
2 parents 5d346d2 + 39f2699 commit fea870e

18 files changed

+2142
-2
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor/
2+
.project
3+
.settings
4+
.buildpath
5+
test/output/

README.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,80 @@
1-
php-sdk
2-
=======
1+
# SparkPost PHP SDK
2+
The official PHP binding for your favorite SparkPost APIs!
3+
4+
Before using this library, you must have a valid API Key.
5+
6+
To get an API Key, please log in to your SparkPost account and generate one in the Settings page.
7+
8+
## Installation
9+
The recommended way to install the SparkPost PHP SDK is through composer.
10+
```
11+
# Install Composer
12+
curl -sS https://getcomposer.org/installer | php
13+
```
14+
Next, run the Composer command to install the SparkPost PHP SDK:
15+
```
16+
composer require messagesystems/php-sdk
17+
```
18+
After installing, you need to require Composer's autoloader:
19+
```
20+
require 'vendor/autoload.php';
21+
```
22+
23+
## Getting Started: Your First Mailing
24+
```
25+
SparkPost::setConfig(["key"=>"YOUR API KEY"]);
26+
27+
try {
28+
// Build your email and send it!
29+
Transmission::send(['campaign'=>'first-mailing',
30+
'from'=>'you@your-company.com',
31+
'subject'=>'First SDK Mailing',
32+
'html'=>'<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>',
33+
'text'=>'Congratulations, {{name}}!! You just sent your very first mailing!',
34+
'substitutionData'=>['name'=>'YOUR FIRST NAME'],
35+
'recipients'=>[['address'=>['name'=>'YOUR FULL NAME', 'email'=>'YOUR EMAIL ADDRESS' ]]]
36+
]);
37+
38+
echo 'Woohoo! You just sent your first mailing!';
39+
} catch (Exception $err) {
40+
echo 'Whoops! Something went wrong';
41+
var_dump($err);
42+
}
43+
```
44+
45+
## Learn More
46+
* For more detailed examples, check our examples:
47+
* [Transmissions](https://github.com/MessageSystems/php-sdk/tree/master/examples/transmission/)
48+
* Read our REST API documentation - <http://www.sparkpost.com/docs/introduction>
49+
50+
## Tips and Tricks
51+
### General
52+
* You _must_ provide at least an API key when instantiating the SparkPost Library - `[ 'key'=>'184ac5480cfdd2bb2859e4476d2e5b1d2bad079bf' ]`
53+
* The SDK's features are namespaced under the various SparkPost API names.
54+
55+
### Transmissions
56+
* If you specify a stored recipient list and inline recipients in a Transmission, you will recieve an error.
57+
* If you specify HTML and/or Plain Text content and then provide RFC-822 encoded content, you will receive an error.
58+
* RFC-822 content is not valid with any other content type.
59+
* If you specify a stored template and also provide inline content via `html` or `text`, you will receive an error.
60+
* By default, open and click tracking are enabled for a transmission.
61+
* By default, a transmission will use the published version of a stored template.
62+
63+
## Development
64+
65+
### Setup
66+
We use [Robo](http://robo.li/) for our task runner.
67+
68+
Run `composer install` inside the directory to install dependecies and development tools including Robo.
69+
70+
### Testing
71+
Once all the dependencies are installed, you can execute the unit tests using `vendor\bin\robo test`
72+
73+
### Contributing
74+
Guidelines for adding issues
75+
76+
Submitting pull requests
77+
78+
Signing our CLA
79+
80+
Our coding standards

RoboFile.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* This is project's console commands configuration for Robo task runner.
4+
*
5+
* @see http://robo.li/
6+
*/
7+
class RoboFile extends \Robo\Tasks
8+
{
9+
public function test () {
10+
$res = $this->taskExec('phpunit --coverage-html test/output/report --bootstrap test/unit/bootstrap.php ./test/unit')->run();
11+
12+
// print message when tests passed
13+
if ($res->wasSuccessful()) $this->say("All tests passed");
14+
15+
return $res();
16+
}
17+
}

composer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "messagesystems/php-sdk",
3+
"description": "SDK for interfacing with messagesystems APIs",
4+
"license": "Apache",
5+
"authors": [
6+
{
7+
"name": "Message Systems",
8+
"email": "info@messagesystems.com"
9+
}
10+
],
11+
"minimum-stability": "stable",
12+
"require": {
13+
"php": ">=5.6.1",
14+
"guzzlehttp/guzzle": "5.0.1"
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "4.3.*",
18+
"codegyre/robo": "0.4.6"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"MessageSystems\\": "lib/MessageSystems/"
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)