summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Song <vincent.wsong@gmail.com>2016-06-13 07:11:10 -0400
committerVincent Song <vincent.wsong@gmail.com>2016-06-13 07:11:10 -0400
commit8165433cbe36fb4a59b802e3892d746202757f0b (patch)
tree20ddd025580c2d8fe9bda4d589059ea53cc20860 /lib
parentec87c5aec0de52271268109f86a1e3aad7fec643 (diff)
downloadphp-sparkpost-8165433cbe36fb4a59b802e3892d746202757f0b.zip
php-sparkpost-8165433cbe36fb4a59b802e3892d746202757f0b.tar.gz
php-sparkpost-8165433cbe36fb4a59b802e3892d746202757f0b.tar.bz2
Sending works, cc/bcc headers don't.
Diffstat (limited to 'lib')
-rw-r--r--lib/SparkPost/Resource.php2
-rw-r--r--lib/SparkPost/SparkPost.php4
-rw-r--r--lib/SparkPost/Transmission.php16
3 files changed, 12 insertions, 10 deletions
diff --git a/lib/SparkPost/Resource.php b/lib/SparkPost/Resource.php
index 57dfd24..91038d5 100644
--- a/lib/SparkPost/Resource.php
+++ b/lib/SparkPost/Resource.php
@@ -20,7 +20,7 @@ class Resource
public function post($payload, $header)
{
- echo $payload;
+ echo "<textarea>" . json_encode($payload) . "</textarea>";
return $this->sparkpost->request('POST', $this->endpoint, $payload, $header);
}
}
diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php
index 53a669b..7b011ed 100644
--- a/lib/SparkPost/SparkPost.php
+++ b/lib/SparkPost/SparkPost.php
@@ -33,10 +33,10 @@ class SparkPost
public function request($method = 'GET', $uri = '', $payload = [], $headers = []) {
if ($this->options['async'] === true && $this->httpClient instanceof HttpAsyncClient) {
- $this->asyncRequest($method, $uri, $payload, $headers);
+ return $this->asyncRequest($method, $uri, $payload, $headers);
}
else {
- $this->syncRequest($method, $uri, $payload, $headers);
+ return $this->syncRequest($method, $uri, $payload, $headers);
}
}
diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php
index ddcde2f..135eb7c 100644
--- a/lib/SparkPost/Transmission.php
+++ b/lib/SparkPost/Transmission.php
@@ -4,12 +4,11 @@ namespace SparkPost;
class Transmission extends Resource
{
- protected $endpoint = 'transmissions';
protected $customHeaders = array();
public function __construct(SparkPost $sparkpost)
{
- parent::__construct($sparkpost, $endpoint);
+ parent::__construct($sparkpost, 'transmissions');
}
public function fixBlindCarbonCopy($payload)
@@ -55,6 +54,8 @@ class Transmission extends Resource
$ccList = &$modifiedPayload['cc'];
$recipientsList = &$modifiedPayload['recipients'];
+ //var_dump($ccList);
+
//if a name exists, then do "name" <email>. Otherwise, just do <email>
if(isset($modifiedPayload['recipients'][0]['name'])) {
$originalRecipient = '"' . $modifiedPayload['recipients'][0]['name']
@@ -78,14 +79,14 @@ class Transmission extends Resource
} else {
$ccCustomHeadersList = $ccCustomHeadersList . ' ' . $ccRecipient['address'];
}
-
+ array_push($recipientsList, $newRecipient);
}
-
+
if(!empty($ccCustomHeadersList)){ //If there are CC'd people
$this->customHeaders = array("CC" => $ccCustomHeadersList);
- }
- //Edits customHeaders and adds array of CSV list of CC emails
+ }
+ //Edits customHeaders and adds array of CSV list of CC emails
}
//delete CC
@@ -98,7 +99,8 @@ class Transmission extends Resource
{
$modifiedPayload = $this->fixBlindCarbonCopy($payload); //Accounts for any BCCs
$modifiedPayload = $this->fixCarbonCopy($modifiedPayload); //Accounts for any CCs
- return parent::post($modifiedPayload, $this->customHeaders);
+ var_dump($this->customHeaders);
+ return parent::post($modifiedPayload, $this->customHeader);
}
}