summaryrefslogtreecommitdiffstats
path: root/examples/transmission/send_transmission_all_fields.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/transmission/send_transmission_all_fields.php')
-rw-r--r--examples/transmission/send_transmission_all_fields.php69
1 files changed, 36 insertions, 33 deletions
diff --git a/examples/transmission/send_transmission_all_fields.php b/examples/transmission/send_transmission_all_fields.php
index 28edbcc..749f0cb 100644
--- a/examples/transmission/send_transmission_all_fields.php
+++ b/examples/transmission/send_transmission_all_fields.php
@@ -3,45 +3,48 @@ namespace Examples\Transmisson;
require_once (dirname(__FILE__).'/../bootstrap.php');
//pull in API key config
-$configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json");
+$configFile = file_get_contents(dirname(__FILE__) . '/../example-config.json');
$config = json_decode($configFile, true);
use SparkPost\SparkPost;
-use SparkPost\Transmission;
+use GuzzleHttp\Client;
+use Ivory\HttpAdapter\Guzzle6HttpAdapter;
-SparkPost::setConfig(array('key'=>$config['api-key']));
+$httpAdapter = new Guzzle6HttpAdapter(new Client());
+$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]);
try{
- $results = Transmission::send(array(
- "campaign"=>"my-campaign",
- "metadata"=>array(
- "sample_campaign"=>true,
- "type"=>"these are custom fields"
- ),
- "substitutionData"=>array(
- "name"=>"Test Name"
- ),
- "description"=>"my description",
- "replyTo"=>"reply@test.com",
- "customHeaders"=>array(
- "X-Custom-Header"=>"Sample Custom Header"
- ),
- "trackOpens"=>false,
- "trackClicks"=>false,
- "from"=>"From Envelope <from@example.com>",
- "html"=>"<p>Hello World! Your name is: {{name}}</p>",
- "text"=>"Hello World!",
- "subject"=>"Example Email: {{name}}",
- "recipients"=>array(
- array(
- "address"=>array(
- "email"=>"john.doe@sample.com"
- )
- )
- )
- ));
- echo 'Congrats you can use your SDK!';
+ $results = $sparky->transmission->send([
+ 'campaign'=>'my-campaign',
+ 'metadata'=>[
+ 'sample_campaign'=>true,
+ 'type'=>'these are custom fields'
+ ],
+ 'substitutionData'=>[
+ 'name'=>'Test Name'
+ ],
+ 'description'=>'my description',
+ 'replyTo'=>'reply@test.com',
+ 'customHeaders'=>[
+ 'X-Custom-Header'=>'Sample Custom Header'
+ ],
+ 'trackOpens'=>false,
+ 'trackClicks'=>false,
+ 'from'=>'From Envelope <from@sparkpostbox.com>',
+ 'html'=>'<p>Hello World! Your name is: {{name}}</p>',
+ 'text'=>'Hello World!',
+ 'subject'=>'Example Email: {{name}}',
+ 'recipients'=>[
+ [
+ 'address'=>[
+ 'email'=>'john.doe@example.com'
+ ]
+ ]
+ ]
+ ]);
+
+ echo 'Congrats you can use your SDK!';
} catch (\Exception $exception) {
- echo $exception->getMessage();
+ echo $exception->getMessage();
}
?>