Skip to content

Commit 3278aae

Browse files
author
Rich Leland
committed
Update transmission examples
* Delete transmission * Additional options, including attachments on send
1 parent 58724c6 commit 3278aae

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
?>

examples/transmission/send_transmission_all_fields.php

+13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
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+
1618
try{
1719
$results = $sparky->transmission->send([
1820
'campaign'=>'my-campaign',
@@ -30,6 +32,10 @@
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 <[email protected]>',
3440
'html'=>'<p>Hello World! Your name is: {{name}}</p>',
3541
'text'=>'Hello World!',
@@ -40,6 +46,13 @@
4046
'email'=>'[email protected]'
4147
]
4248
]
49+
],
50+
'attachments'=>[
51+
[
52+
'type'=>'text/csv',
53+
'name'=>'testing.csv',
54+
'data'=>base64_encode($data)
55+
]
4356
]
4457
]);
4558

0 commit comments

Comments
 (0)