File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Examples \Transmisson ;
3+ require_once (dirname (__FILE__ ).'/../bootstrap.php ' );
4+
5+ //pull in API key config
6+ $ configFile = file_get_contents (dirname (__FILE__ ) . '/../example-config.json ' );
7+ $ config = json_decode ($ configFile , true );
8+
9+ use SparkPost \SparkPost ;
10+ use GuzzleHttp \Client ;
11+ use Ivory \HttpAdapter \Guzzle6HttpAdapter ;
12+
13+ $ httpAdapter = new Guzzle6HttpAdapter (new Client ());
14+ $ sparky = new SparkPost ($ httpAdapter , ['key ' =>$ config ['api-key ' ]]);
15+
16+ try {
17+ $ results = $ sparky ->transmission ->delete ('transmission-id ' );
18+ echo 'Transmission deleted! ' ;
19+ } catch (\Exception $ exception ) {
20+ echo $ exception ->getMessage ();
21+ }
22+ ?>
Original file line number Diff line number Diff line change 1313$ httpAdapter = new Guzzle6HttpAdapter (new Client ());
1414$ sparky = new SparkPost ($ httpAdapter , ['key ' =>$ config ['api-key ' ]]);
1515
16+ $ data = file_get_contents ('/path/to/test.csv ' );
17+
1618try {
1719 $ results = $ sparky ->transmission ->send ([
1820 'campaign ' =>'my-campaign ' ,
3032 ],
3133 'trackOpens ' =>false ,
3234 'trackClicks ' =>false ,
35+ 'sandbox ' =>false ,
36+ 'inlineCss ' =>true ,
37+ 'transactional ' =>true ,
38+ 'startTime ' =>'2016-03-17T08:00:00-04:00 ' ,
3339 'from ' =>'From Envelope <from@sparkpostbox.com> ' ,
3440 'html ' =>'<p>Hello World! Your name is: {{name}}</p> ' ,
3541 'text ' =>'Hello World! ' ,
4046 'email ' =>'john.doe@example.com '
4147 ]
4248 ]
49+ ],
50+ 'attachments ' =>[
51+ [
52+ 'type ' =>'text/csv ' ,
53+ 'name ' =>'testing.csv ' ,
54+ 'data ' =>base64_encode ($ data )
55+ ]
4356 ]
4457 ]);
4558
You can’t perform that action at this time.
0 commit comments