3
3
require_once (dirname (__FILE__ ).'/../bootstrap.php ' );
4
4
use SparkPost \SparkPost ;
5
5
use SparkPost \Transmission ;
6
+ use GuzzleHttp \Client ;
7
+ use Ivory \HttpAdapter \Guzzle6HttpAdapter ;
6
8
7
- $ key = 'YOURAPIKEY ' ;
8
- SparkPost::setConfig (array ('key ' =>$ key ));
9
+ $ key = 'YOUR API KEY ' ;
10
+ $ httpAdapter = new Guzzle6HttpAdapter (new Client ());
11
+ SparkPost::configure ($ httpAdapter , ['key ' =>$ key ]);
12
+
13
+ // TODO: update all from emails to = sandbox domain
9
14
10
15
try {
11
- $ results = Transmission::send (array (
16
+ $ results = Transmission::send ([
12
17
"campaign " =>"my-campaign " ,
13
- "metadata " =>array (
18
+ "metadata " =>[
14
19
"sample_campaign " =>true ,
15
20
"type " =>"these are custom fields "
16
- ) ,
17
- "substitutionData " =>array (
21
+ ] ,
22
+ "substitutionData " =>[
18
23
"name " =>"Test Name "
19
- ) ,
24
+ ] ,
20
25
"description " =>"my description " ,
21
26
"replyTo " =>"reply@test.com " ,
22
- "customHeaders " =>array (
27
+ "customHeaders " =>[
23
28
"X-Custom-Header " =>"Sample Custom Header "
24
- ) ,
29
+ ] ,
25
30
"trackOpens " =>false ,
26
31
"trackClicks " =>false ,
27
- "from " =>"From Envelope <from@example .com> " ,
32
+ "from " =>"From Envelope <from@sparkpostbox .com> " ,
28
33
"html " =>"<p>Hello World! Your name is: {{name}}</p> " ,
29
34
"text " =>"Hello World! " ,
30
35
"subject " =>"Example Email: {{name}} " ,
31
- "recipients " =>array (
32
- array (
33
- "address " =>array (
34
- "email " =>"john.doe@sample.com "
35
- )
36
- )
37
- )
38
- ));
36
+ "recipients " =>[
37
+ [
38
+ "address " =>[
39
+ "email " =>"john.doe@example.com "
40
+ ]
41
+ ]
42
+ ]
43
+ ]);
44
+
45
+ var_dump ($ results );
39
46
echo 'Congrats you can use your SDK! ' ;
40
47
} catch (\Exception $ exception ) {
41
48
echo $ exception ->getMessage ();
42
49
}
43
- ?>
50
+ ?>
0 commit comments