summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAvi Goldman <avrahamymgoldman@gmail.com>2017-01-06 09:09:36 -0500
committerGitHub <noreply@github.com>2017-01-06 09:09:36 -0500
commitf4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765 (patch)
tree590ea1a6299fba349d0b720c0ac9f9309a7121dd /examples
parentc54abe82f41d7a6f1b857adf4610d82dba020426 (diff)
parent1abdc8bde168614ce055f9709de5dc788a7a46b9 (diff)
downloadphp-sparkpost-f4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765.zip
php-sparkpost-f4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765.tar.gz
php-sparkpost-f4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765.tar.bz2
Added debug option
Added debug option
Diffstat (limited to 'examples')
-rw-r--r--examples/debug/index.php42
-rw-r--r--examples/message-events/get_message_events.php2
-rw-r--r--examples/templates/create_template.php12
-rw-r--r--examples/templates/preview_template.php4
-rw-r--r--examples/templates/update_template.php4
5 files changed, 53 insertions, 11 deletions
diff --git a/examples/debug/index.php b/examples/debug/index.php
new file mode 100644
index 0000000..84120f0
--- /dev/null
+++ b/examples/debug/index.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Examples\Templates;
+
+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, [
+ "key" => "YOUR_API_KEY",
+ // This will expose your API KEY - do not use this in production.
+ "debug" => true
+]);
+
+$promise = $sparky->request('GET', 'templates');
+
+try {
+ $response = $promise->wait();
+
+ var_dump($response);
+
+ echo "Request:\n";
+ print_r($response->getRequest());
+
+ echo "Response:\n";
+ echo $response->getStatusCode()."\n";
+ print_r($response->getBody())."\n";
+} catch (\Exception $e) {
+ echo "Request:\n";
+ print_r($e->getRequest());
+
+ echo "Exception:\n";
+ echo $e->getCode()."\n";
+ echo $e->getMessage()."\n";
+}
diff --git a/examples/message-events/get_message_events.php b/examples/message-events/get_message_events.php
index bff4300..e027df1 100644
--- a/examples/message-events/get_message_events.php
+++ b/examples/message-events/get_message_events.php
@@ -16,7 +16,7 @@ $httpClient = new GuzzleAdapter(new Client());
$sparky = new SparkPost($httpClient, $options);
$promise = $sparky->request('GET', 'message-events', [
- 'campaign_ids' => 'CAMPAIGN_ID'
+ 'campaign_ids' => 'CAMPAIGN_ID',
]);
try {
diff --git a/examples/templates/create_template.php b/examples/templates/create_template.php
index c25b900..826b076 100644
--- a/examples/templates/create_template.php
+++ b/examples/templates/create_template.php
@@ -16,12 +16,12 @@ $httpClient = new GuzzleAdapter(new Client());
$sparky = new SparkPost($httpClient, $options);
$promise = $sparky->request('POST', 'templates', [
- "name" => "PHP example template",
- "content" => [
- "from" => "from@YOUR_DOMAIN",
- "subject" => "Your Subject",
- "html" => "<b>Write your message here.</b>"
- ]
+ 'name' => 'PHP example template',
+ 'content' => [
+ 'from' => 'from@YOUR_DOMAIN',
+ 'subject' => 'Your Subject',
+ 'html' => '<b>Write your message here.</b>',
+ ],
]);
try {
diff --git a/examples/templates/preview_template.php b/examples/templates/preview_template.php
index cdfa055..0f0a1db 100644
--- a/examples/templates/preview_template.php
+++ b/examples/templates/preview_template.php
@@ -17,8 +17,8 @@ $sparky = new SparkPost($httpClient, $options);
$promise = $sparky->request('POST', 'templates/TEMPLATE_ID/preview?draft=true', [
'substitution_data' => [
- 'some_key' => 'some_value'
- ]
+ 'some_key' => 'some_value',
+ ],
]);
try {
diff --git a/examples/templates/update_template.php b/examples/templates/update_template.php
index 1f467ce..4da186c 100644
--- a/examples/templates/update_template.php
+++ b/examples/templates/update_template.php
@@ -17,8 +17,8 @@ $sparky = new SparkPost($httpClient, $options);
$promise = $sparky->request('PUT', 'templates/TEMPLATE_ID', [
'options' => [
- 'open_tracking' => true
- ]
+ 'open_tracking' => true,
+ ],
]);
try {