diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bootstrap.php | 4 | ||||
-rw-r--r-- | examples/transmission/delete_transmission.php | 15 | ||||
-rw-r--r-- | examples/transmission/get_all_transmissions.php | 15 | ||||
-rw-r--r-- | examples/transmission/get_transmission.php | 15 | ||||
-rw-r--r-- | examples/transmission/rfc822.php | 27 | ||||
-rw-r--r-- | examples/transmission/send_transmission_all_fields.php | 81 | ||||
-rw-r--r-- | examples/transmission/simple_send.php | 37 | ||||
-rw-r--r-- | examples/transmission/stored_recipients_inline_content.php | 30 | ||||
-rw-r--r-- | examples/transmission/stored_template_send.php | 31 | ||||
-rw-r--r-- | examples/unwrapped/create_template.php | 17 | ||||
-rw-r--r-- | examples/unwrapped/get_webhooks.php | 9 |
11 files changed, 145 insertions, 136 deletions
diff --git a/examples/bootstrap.php b/examples/bootstrap.php index 774b159..688d53e 100644 --- a/examples/bootstrap.php +++ b/examples/bootstrap.php @@ -1,3 +1,3 @@ <?php - require_once dirname(__FILE__).'/../vendor/autoload.php'; -?>
\ No newline at end of file + +require_once dirname(__FILE__).'/../vendor/autoload.php'; diff --git a/examples/transmission/delete_transmission.php b/examples/transmission/delete_transmission.php index 9459066..f7d0530 100644 --- a/examples/transmission/delete_transmission.php +++ b/examples/transmission/delete_transmission.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,14 +13,13 @@ 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->delete('transmission-id'); echo 'Transmission deleted!'; } 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"; } -?> diff --git a/examples/transmission/get_all_transmissions.php b/examples/transmission/get_all_transmissions.php index a465056..c037b2d 100644 --- a/examples/transmission/get_all_transmissions.php +++ b/examples/transmission/get_all_transmissions.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,14 +13,13 @@ 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->all(); echo 'Congrats! You got a list of all your transmissions from 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"; } -?> diff --git a/examples/transmission/get_transmission.php b/examples/transmission/get_transmission.php index 879e9c3..5d59740 100644 --- a/examples/transmission/get_transmission.php +++ b/examples/transmission/get_transmission.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,14 +13,13 @@ 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->find('Your Transmission ID'); echo 'Congrats! You retrieved your transmission from 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"; } -?> diff --git a/examples/transmission/rfc822.php b/examples/transmission/rfc822.php index 5ec5aef..df2b06b 100644 --- a/examples/transmission/rfc822.php +++ b/examples/transmission/rfc822.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,23 +13,22 @@ 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([ - 'recipients'=>[ + 'recipients' => [ [ - 'address'=>[ - 'email'=>'john.doe@example.com' - ] - ] + 'address' => [ + 'email' => 'john.doe@example.com', + ], + ], ], - 'rfc822'=>"Content-Type: text/plain\nFrom: From Envelope <from@sparkpostbox.com>\nSubject: Example Email\n\nHello World" + 'rfc822' => "Content-Type: text/plain\nFrom: From Envelope <from@sparkpostbox.com>\nSubject: Example Email\n\nHello World", ]); 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"; } -?> diff --git a/examples/transmission/send_transmission_all_fields.php b/examples/transmission/send_transmission_all_fields.php index 9db99d2..26cb96d 100644 --- a/examples/transmission/send_transmission_all_fields.php +++ b/examples/transmission/send_transmission_all_fields.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,58 +13,57 @@ 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']]); $data = file_get_contents('/path/to/test.csv'); -try{ +try { $results = $sparky->transmission->send([ - 'campaign'=>'my-campaign', - 'metadata'=>[ - 'sample_campaign'=>true, - 'type'=>'these are custom fields' + 'campaign' => 'my-campaign', + 'metadata' => [ + 'sample_campaign' => true, + 'type' => 'these are custom fields', ], - 'substitutionData'=>[ - 'name'=>'Test Name' + 'substitutionData' => [ + 'name' => 'Test Name', ], - 'description'=>'my description', - 'replyTo'=>'reply@test.com', - 'customHeaders'=>[ - 'X-Custom-Header'=>'Sample Custom Header' + 'description' => 'my description', + 'replyTo' => 'reply@test.com', + 'customHeaders' => [ + 'X-Custom-Header' => 'Sample Custom Header', ], - 'trackOpens'=>false, - 'trackClicks'=>false, - 'sandbox'=>false, - 'inlineCss'=>true, - 'transactional'=>true, - 'startTime'=>'2016-03-17T08:00:00-04:00', - 'from'=>[ + 'trackOpens' => false, + 'trackClicks' => false, + 'sandbox' => false, + 'inlineCss' => true, + 'transactional' => true, + 'startTime' => '2016-03-17T08:00:00-04:00', + 'from' => [ 'name' => 'From Envelope', - 'email' => 'from@sparkpostbox.com' + 'email' => 'from@sparkpostbox.com', ], - 'html'=>'<p>Hello World! Your name is: {{name}}</p>', - 'text'=>'Hello World!', - 'subject'=>'Example Email: {{name}}', - 'recipients'=>[ + 'html' => '<p>Hello World! Your name is: {{name}}</p>', + 'text' => 'Hello World!', + 'subject' => 'Example Email: {{name}}', + 'recipients' => [ [ - 'address'=>[ - 'email'=>'john.doe@example.com' - ] - ] + 'address' => [ + 'email' => 'john.doe@example.com', + ], + ], ], - 'attachments'=>[ + 'attachments' => [ [ - 'type'=>'text/csv', - 'name'=>'testing.csv', - 'data'=>base64_encode($data) - ] - ] + 'type' => 'text/csv', + 'name' => 'testing.csv', + 'data' => base64_encode($data), + ], + ], ]); 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"; } -?> 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"; } -?> diff --git a/examples/transmission/stored_recipients_inline_content.php b/examples/transmission/stored_recipients_inline_content.php index 8b16456..503908b 100644 --- a/examples/transmission/stored_recipients_inline_content.php +++ b/examples/transmission/stored_recipients_inline_content.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,26 +13,24 @@ 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([ - 'campaign'=>'my-campaign', - 'from'=>[ + 'campaign' => 'my-campaign', + 'from' => [ 'name' => 'From Envelope', - 'email' => 'from@sparkpostbox.com' + 'email' => 'from@sparkpostbox.com', ], - 'html'=>'<p>Hello World! Your name is: {{name}}</p>', - 'text'=>'Hello World!', - 'subject'=>'Example Email: {{name}}', - 'recipientList'=>'Example List' + 'html' => '<p>Hello World! Your name is: {{name}}</p>', + 'text' => 'Hello World!', + 'subject' => 'Example Email: {{name}}', + 'recipientList' => 'Example List', ]); 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"; } -?> diff --git a/examples/transmission/stored_template_send.php b/examples/transmission/stored_template_send.php index 4d4adfe..5ce48e4 100644 --- a/examples/transmission/stored_template_send.php +++ b/examples/transmission/stored_template_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,27 +13,26 @@ 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', ], - 'recipients'=>[ + 'recipients' => [ [ - 'address'=>[ - 'email'=>'john.doe@example.com' - ] - ] + 'address' => [ + 'email' => 'john.doe@example.com', + ], + ], ], - 'template'=>'my-first-email' + 'template' => 'my-first-email', ]); 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"; } -?> diff --git a/examples/unwrapped/create_template.php b/examples/unwrapped/create_template.php index 45239b0..89523f1 100644 --- a/examples/unwrapped/create_template.php +++ b/examples/unwrapped/create_template.php @@ -1,9 +1,11 @@ <?php + namespace Examples\Unwrapped; -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,7 +13,7 @@ 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 { // define the endpoint @@ -19,16 +21,15 @@ try { $templateConfig = [ 'name' => 'Summer Sale!', - 'id'=>'summer-sale', - 'content'=> [ + 'id' => 'summer-sale', + 'content' => [ 'from' => 'from@sparkpostbox.com', 'subject' => 'Summer deals', - 'html' => '<b>Check out these deals!</b>' - ] + 'html' => '<b>Check out these deals!</b>', + ], ]; $results = $sparky->templates->create($templateConfig); echo 'Congrats! You created a template using SparkPost!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?> diff --git a/examples/unwrapped/get_webhooks.php b/examples/unwrapped/get_webhooks.php index a71cb3f..e149b21 100644 --- a/examples/unwrapped/get_webhooks.php +++ b/examples/unwrapped/get_webhooks.php @@ -1,9 +1,11 @@ <?php + namespace Examples\Unwrapped; -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,7 +13,7 @@ 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 { $sparky->setupUnwrapped('webhooks'); @@ -22,4 +24,3 @@ try { } catch (\Exception $exception) { echo $exception->getMessage(); } -?> |