Skip to content

Commit

Permalink
Merge pull request #59 from SparkPost/ISSUE-46
Browse files Browse the repository at this point in the history
Update transmission examples
  • Loading branch information
richleland committed Mar 25, 2016
2 parents 58724c6 + 3278aae commit 5726744
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/transmission/delete_transmission.php
@@ -0,0 +1,22 @@
<?php
namespace Examples\Transmisson;
require_once (dirname(__FILE__).'/../bootstrap.php');

//pull in API key config
$configFile = file_get_contents(dirname(__FILE__) . '/../example-config.json');
$config = json_decode($configFile, true);

use SparkPost\SparkPost;
use GuzzleHttp\Client;
use Ivory\HttpAdapter\Guzzle6HttpAdapter;

$httpAdapter = new Guzzle6HttpAdapter(new Client());
$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]);

try {
$results = $sparky->transmission->delete('transmission-id');
echo 'Transmission deleted!';
} catch (\Exception $exception) {
echo $exception->getMessage();
}
?>
13 changes: 13 additions & 0 deletions examples/transmission/send_transmission_all_fields.php
Expand Up @@ -13,6 +13,8 @@
$httpAdapter = new Guzzle6HttpAdapter(new Client());
$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]);

$data = file_get_contents('/path/to/test.csv');

try{
$results = $sparky->transmission->send([
'campaign'=>'my-campaign',
Expand All @@ -30,6 +32,10 @@
],
'trackOpens'=>false,
'trackClicks'=>false,
'sandbox'=>false,
'inlineCss'=>true,
'transactional'=>true,
'startTime'=>'2016-03-17T08:00:00-04:00',
'from'=>'From Envelope <from@sparkpostbox.com>',
'html'=>'<p>Hello World! Your name is: {{name}}</p>',
'text'=>'Hello World!',
Expand All @@ -40,6 +46,13 @@
'email'=>'john.doe@example.com'
]
]
],
'attachments'=>[
[
'type'=>'text/csv',
'name'=>'testing.csv',
'data'=>base64_encode($data)
]
]
]);

Expand Down

0 comments on commit 5726744

Please sign in to comment.