summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Goldman <avrahamymgoldman@gmail.com>2016-06-22 11:46:09 -0400
committerAvi Goldman <avrahamymgoldman@gmail.com>2016-06-22 11:46:09 -0400
commit9cf58b85b7c771af97b5d95735c090551809db7f (patch)
tree1d9d2f58efa146a4ed4e43eb4c3386bcba38d91c
parentce821d64191a9b0b101cb9d93e4107691d952c3d (diff)
downloadphp-sparkpost-9cf58b85b7c771af97b5d95735c090551809db7f.zip
php-sparkpost-9cf58b85b7c771af97b5d95735c090551809db7f.tar.gz
php-sparkpost-9cf58b85b7c771af97b5d95735c090551809db7f.tar.bz2
wrote examples for transmissions
-rw-r--r--examples/transmissions/create_transmission.php42
-rw-r--r--examples/transmissions/create_transmission_with_cc_and_bcc.php48
-rw-r--r--examples/transmissions/delete_transmission.php28
-rw-r--r--examples/transmissions/get_all_transmissions.php28
4 files changed, 146 insertions, 0 deletions
diff --git a/examples/transmissions/create_transmission.php b/examples/transmissions/create_transmission.php
new file mode 100644
index 0000000..b21fc1f
--- /dev/null
+++ b/examples/transmissions/create_transmission.php
@@ -0,0 +1,42 @@
+<?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' => [
+ 'from'=> [
+ 'name' => 'SparkPost Team',
+ 'email' => 'from@sparkpostbox.com'
+ ],
+ 'subject'=>'First Mailing From PHP',
+ 'html'=>'<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>',
+ 'text'=>'Congratulations, {{name}}!! You just sent your very first mailing!'
+ ],
+ 'substitution_data'=> ['name'=>'YOUR_FIRST_NAME'],
+ 'recipients'=> [
+ [ 'address' => 'YOUR_NAME <YOUR_EMAIL>' ]
+ ]
+]);
+
+try {
+ $response = $promise->wait();
+ echo $response->getStatusCode() . "\n";
+ print_r($response->getBody());
+} catch (Exception $e) {
+ echo $e->getCode() . "\n";
+ echo $e->getMessage() . "\n";
+}
+?> \ No newline at end of file
diff --git a/examples/transmissions/create_transmission_with_cc_and_bcc.php b/examples/transmissions/create_transmission_with_cc_and_bcc.php
new file mode 100644
index 0000000..4c12f81
--- /dev/null
+++ b/examples/transmissions/create_transmission_with_cc_and_bcc.php
@@ -0,0 +1,48 @@
+<?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' => [
+ 'from'=> [
+ 'name' => 'SparkPost Team',
+ 'email' => 'from@sparkpostbox.com'
+ ],
+ 'subject'=>'First Mailing From PHP',
+ 'html'=>'<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>',
+ 'text'=>'Congratulations, {{name}}!! You just sent your very first mailing!'
+ ],
+ 'substitution_data'=> ['name'=>'YOUR_FIRST_NAME'],
+ 'recipients'=> [
+ [ 'address' => 'YOUR_NAME <YOUR_EMAIL>' ]
+ ],
+ 'cc'=> [
+ [ 'address' => 'ANOTHER_NAME <ANOTHER_EMAIL>' ]
+ ],
+ 'bcc'=> [
+ [ 'address' => 'AND_ANOTHER_NAME <AND_ANOTHER_EMAIL>' ]
+ ]
+]);
+
+try {
+ $response = $promise->wait();
+ echo $response->getStatusCode() . "\n";
+ print_r($response->getBody());
+} catch (Exception $e) {
+ echo $e->getCode() . "\n";
+ echo $e->getMessage() . "\n";
+}
+?> \ No newline at end of file
diff --git a/examples/transmissions/delete_transmission.php b/examples/transmissions/delete_transmission.php
new file mode 100644
index 0000000..ca2bd01
--- /dev/null
+++ b/examples/transmissions/delete_transmission.php
@@ -0,0 +1,28 @@
+<?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->delete('TRANSMISSION_ID');
+
+try {
+ $response = $promise->wait();
+ echo $response->getStatusCode() . "\n";
+ print_r($response->getBody());
+} catch (Exception $e) {
+ echo $e->getCode() . "\n";
+ echo $e->getMessage() . "\n";
+}
+?> \ No newline at end of file
diff --git a/examples/transmissions/get_all_transmissions.php b/examples/transmissions/get_all_transmissions.php
new file mode 100644
index 0000000..5b48971
--- /dev/null
+++ b/examples/transmissions/get_all_transmissions.php
@@ -0,0 +1,28 @@
+<?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->get();
+
+try {
+ $response = $promise->wait();
+ echo $response->getStatusCode() . "\n";
+ print_r($response->getBody());
+} catch (Exception $e) {
+ echo $e->getCode() . "\n";
+ echo $e->getMessage() . "\n";
+}
+?> \ No newline at end of file