File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Examples \Templates ;
4
+
5
+ require dirname (__FILE__ ).'/../bootstrap.php ' ;
6
+
7
+ use SparkPost \SparkPost ;
8
+ use GuzzleHttp \Client ;
9
+ use Http \Adapter \Guzzle6 \Client as GuzzleAdapter ;
10
+
11
+ $ httpClient = new GuzzleAdapter (new Client ());
12
+
13
+ /*
14
+ * configure options in example-options.json
15
+ */
16
+ $ sparky = new SparkPost ($ httpClient , [
17
+ "key " => "YOUR_API_KEY " ,
18
+ // This will expose your API KEY - do not use this in production.
19
+ "debug " => true
20
+ ]);
21
+
22
+ $ promise = $ sparky ->request ('GET ' , 'templates ' );
23
+
24
+ try {
25
+ $ response = $ promise ->wait ();
26
+
27
+ var_dump ($ response );
28
+
29
+ echo "Request: \n" ;
30
+ print_r ($ response ->getRequest ());
31
+
32
+ echo "Response: \n" ;
33
+ echo $ response ->getStatusCode ()."\n" ;
34
+ print_r ($ response ->getBody ())."\n" ;
35
+ } catch (\Exception $ e ) {
36
+ echo "Request: \n" ;
37
+ print_r ($ e ->getRequest ());
38
+
39
+ echo "Exception: \n" ;
40
+ echo $ e ->getCode ()."\n" ;
41
+ echo $ e ->getMessage ()."\n" ;
42
+ }
You can’t perform that action at this time.
0 commit comments