diff options
Diffstat (limited to 'examples/transmission/simple_send.php')
-rw-r--r-- | examples/transmission/simple_send.php | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/examples/transmission/simple_send.php b/examples/transmission/simple_send.php index 5d2d6e3..6bd0336 100644 --- a/examples/transmission/simple_send.php +++ b/examples/transmission/simple_send.php @@ -1,9 +1,11 @@ <?php + namespace Examples\Transmisson; -require_once (dirname(__FILE__).'/../bootstrap.php'); + +require_once dirname(__FILE__).'/../bootstrap.php'; //pull in API key config -$configFile = file_get_contents(dirname(__FILE__) . '/../example-config.json'); +$configFile = file_get_contents(dirname(__FILE__).'/../example-config.json'); $config = json_decode($configFile, true); use SparkPost\SparkPost; @@ -11,29 +13,28 @@ use GuzzleHttp\Client; use Ivory\HttpAdapter\Guzzle6HttpAdapter; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); +$sparky = new SparkPost($httpAdapter, ['key' => $config['api-key']]); try { $results = $sparky->transmission->send([ - 'from'=>[ + 'from' => [ 'name' => 'From Envelope', - 'email' => 'from@sparkpostbox.com' + 'email' => 'from@sparkpostbox.com', ], - 'html'=>'<p>Hello World!</p>', - 'text'=>'Hello World!', - 'subject'=>'Example Email', - 'recipients'=>[ + 'html' => '<p>Hello World!</p>', + 'text' => 'Hello World!', + 'subject' => 'Example Email', + 'recipients' => [ [ - 'address'=>[ - 'email'=>'john.doe@example.com' - ] - ] - ] + 'address' => [ + 'email' => 'john.doe@example.com', + ], + ], + ], ]); echo 'Congrats! You sent an email using SparkPost!'; } catch (\Exception $exception) { - echo $exception->getAPIMessage() . "\n"; - echo $exception->getAPICode() . "\n"; - echo $exception->getAPIDescription() . "\n"; + echo $exception->getAPIMessage()."\n"; + echo $exception->getAPICode()."\n"; + echo $exception->getAPIDescription()."\n"; } -?> |