summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAvi Goldman <avrahamymgoldman@gmail.com>2017-01-04 12:44:39 -0500
committerAvi Goldman <avrahamymgoldman@gmail.com>2017-01-04 12:44:39 -0500
commit23448f01c8f3f2ebff2099cfe4f85040ffbe8c7c (patch)
treed6881cced06d4ddbdfca4a0d0fed3e2596fc6e50 /examples
parentf9d5c0cae873cdc257797ea9ffe5e763df719b20 (diff)
downloadphp-sparkpost-23448f01c8f3f2ebff2099cfe4f85040ffbe8c7c.zip
php-sparkpost-23448f01c8f3f2ebff2099cfe4f85040ffbe8c7c.tar.gz
php-sparkpost-23448f01c8f3f2ebff2099cfe4f85040ffbe8c7c.tar.bz2
added debug example
Diffstat (limited to 'examples')
-rw-r--r--examples/debug/index.php42
1 files changed, 42 insertions, 0 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";
+}