diff options
author | nornholdj <nornholdj@gmail.com> | 2014-10-30 11:33:00 -0400 |
---|---|---|
committer | nornholdj <nornholdj@gmail.com> | 2014-10-30 11:33:00 -0400 |
commit | 02c1073edad6572e1c88c8649b4a219762340b49 (patch) | |
tree | d5eed846cafb6b6ffaa292495ddc854620c90240 | |
parent | e8e8cabb77bdf994a78f3f3a66ae3bdeb2da3d48 (diff) | |
download | php-sparkpost-02c1073edad6572e1c88c8649b4a219762340b49.zip php-sparkpost-02c1073edad6572e1c88c8649b4a219762340b49.tar.gz php-sparkpost-02c1073edad6572e1c88c8649b4a219762340b49.tar.bz2 |
MA-946 #time 1h 30m updated readme file for parity with the node-sdk
-rw-r--r-- | README.md | 92 | ||||
-rw-r--r-- | RoboFile.php | 7 | ||||
-rw-r--r-- | test/unit/ConfigurationTest.php (renamed from test/unit/configurationTest.php) | 0 | ||||
-rw-r--r-- | test/unit/TransmissionTest.php (renamed from test/unit/transmissionTest.php) | 0 |
4 files changed, 91 insertions, 8 deletions
@@ -1,2 +1,92 @@ -php-sdk +# SparkPost PHP SDK ======= +The official PHP binding for your favorite SparkPost APIs! + +Before using this library, you must have a valid API Key. + +To get an API Key, please log in to your SparkPost account and generate one in the Settings page. + +## Installation +============ +The recommended way to install the SparkPost PHP SDK is through composer. +``` +# Install Composer +curl -sS https:// getcomposer.org/installer | php +``` +Next, run the Composer command to install the SparkPost PHP SDK: +``` +composer require messagesystems/php-sdk +``` +After installing, you need to require Composer's autoloader: +``` +require 'vendor/autoload.php'; +``` + +## Getting Started: Your First Mailing +``` +$sparkpost = new SparkPost(["key"=>"YOUR API KEY"]); + +$transmission = $sparkpost->transmission(); + +// Add some template data to your email +$transmission->setCampaign('first-mailing')-> + setReturnPath('bounces@sparkpost.com')-> + setFrom('you@your-company.com')-> + setSubject('First SDK Mailing')-> + setHTMLContent('<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>')-> + setTextContent('Congratulations, {{name}}!! You just sent your very first mailing!')-> + setSubstitutionData(['name'=>'YOUR FIRST NAME']); + +// Pick someone to receive your email +$transmission->addRecipient(['address'=>['name'=>'YOUR FULL NAME', 'email'=>'YOUR EMAIL ADDRESS' ]]); + +// Send it off into the world! +try { + $response = $transmission->send(); + echo 'Woohoo! You just sent your first mailing!'; +} catch (Exception $err) { + echo 'Whoops! Something went wrong'; + var_dump($err); +} +``` + +## Learn More +* For more detailed examples, check our examples: + * [Transmissions](https://github.com/MessageSystems/php-sdk/tree/master/examples/transmission/) +* Read our REST API documentation - <http://docs.thecloudplaceholderapiv1.apiary.io/> + +## Tips and Tricks +### General +* You _must_ provide at least an API key when instantiating the SparkPost Library - `{ key: '184ac5480cfdd2bb2859e4476d2e5b1d2bad079bf' }` +* The SDK's features are namespaced under the various SparkPost API names. +* There are two ways to provide values to each namespace of the SDK: + - On instantiation, you pass in a well-formed object (See examples). + - You use the helper methods to incrementally create a well-formed object. These helper methods are chainable (See examples). + +### Transmissions +* If you specify a stored recipient list and inline recipients in a Transmission, whichever was provided last will be used. + * If you call addRecipient and then useRecipientList, the latter will overwrite the former. +* If you specify HTML and/or Plain Text content and then provide RFC-822 encoded content, you will receive an error. + * RFC-822 content is not valid with any other content type. +* If you specify a stored template and also provide inline content via setHTMLContent or setTextContent, you will receive an error. +* By default, open and click tracking are enabled for a transmission. +* By default, a transmission will use the published version of a stored template. + +## Development + +### Setup +We use [Robo](http://robo.li/) for our task runner, please follow the instructions on their website to install Robo. + +Run `composer install` inside the directory to install dependecies and development tools. + +### Testing +Once all the dependencies are installed, you can execute the unit tests using `vendor\bin\robo test` + +### Contributing +Guidelines for adding issues + +Submitting pull requests + +Signing our CLA + +Our coding standards
\ No newline at end of file diff --git a/RoboFile.php b/RoboFile.php index 9b7df90..571da64 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -7,18 +7,11 @@ class RoboFile extends \Robo\Tasks { public function test () { -// $coverage = new PHP_CodeCoverage(); -// $coverage->start('PHP-SDK Unit Tests'); -// $this->taskPHPUnit('./test/unit/')->run(); $res = $this->taskExec('phpunit --coverage-html test/output/report --bootstrap test/unit/bootstrap.php ./test/unit')->run(); // print message when tests passed if ($res->wasSuccessful()) $this->say("All tests passed"); -// $coverage->stop(); -// $writer = new PHP_CodeCoverage_Report_HTML; -// $writer->process($coverage, 'test/output/report'); - return $res(); } }
\ No newline at end of file diff --git a/test/unit/configurationTest.php b/test/unit/ConfigurationTest.php index 52c60be..52c60be 100644 --- a/test/unit/configurationTest.php +++ b/test/unit/ConfigurationTest.php diff --git a/test/unit/transmissionTest.php b/test/unit/TransmissionTest.php index 3d2f6d3..3d2f6d3 100644 --- a/test/unit/transmissionTest.php +++ b/test/unit/TransmissionTest.php |