diff options
Diffstat (limited to 'examples/transmission/simple_send.php')
-rw-r--r-- | examples/transmission/simple_send.php | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/examples/transmission/simple_send.php b/examples/transmission/simple_send.php index eafc176..5844ecc 100644 --- a/examples/transmission/simple_send.php +++ b/examples/transmission/simple_send.php @@ -3,30 +3,32 @@ namespace Examples\Transmisson; 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; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); try { - $results = Transmission::send(array( - "from"=>"From Envelope <from@example.com>", - "html"=>"<p>Hello World!</p>", - "text"=>"Hello World!", - "subject"=>"Example Email", - "recipients"=>array( - array( - "address"=>array( - "email"=>"john.doe@example.com" - ) - ) - ) - )); - echo 'Congrats you can use your SDK!'; + $results = $sparky->transmission->send([ + 'from'=>'From Envelope <from@sparkpostbox.com>', + 'html'=>'<p>Hello World!</p>', + 'text'=>'Hello World!', + 'subject'=>'Example Email', + 'recipients'=>[ + [ + 'address'=>[ + 'email'=>'john.doe@example.com' + ] + ] + ] + ]); + echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { - echo $exception->getMessage(); + echo $exception->getMessage(); } ?> |