diff options
Diffstat (limited to 'examples/transmissions/create_transmission_with_template.php')
-rw-r--r-- | examples/transmissions/create_transmission_with_template.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/transmissions/create_transmission_with_template.php b/examples/transmissions/create_transmission_with_template.php new file mode 100644 index 0000000..e8f3fb6 --- /dev/null +++ b/examples/transmissions/create_transmission_with_template.php @@ -0,0 +1,38 @@ +<?php + +namespace Examples\Transmissions; + +require dirname(__FILE__).'/../bootstrap.php'; + +use SparkPost\SparkPost; +use GuzzleHttp\Client; +use Http\Adapter\Guzzle6\Client as GuzzleAdapter; + +$httpClient = new GuzzleAdapter(new Client()); + +/* + * configure options in example-options.json + */ +$sparky = new SparkPost($httpClient, $options); + +$promise = $sparky->transmissions->post([ + 'content' => ['template_id' => 'TEMPLATE_ID'], + 'substitution_data' => ['name' => 'YOUR_FIRST_NAME'], + 'recipients' => [ + [ + 'address' => [ + 'name' => 'YOUR_NAME', + 'email' => 'YOUR_EMAIL', + ], + ], + ], +]); + +try { + $response = $promise->wait(); + echo $response->getStatusCode()."\n"; + print_r($response->getBody())."\n"; +} catch (\Exception $e) { + echo $e->getCode()."\n"; + echo $e->getMessage()."\n"; +} |