コード例 #1
0
 $postSendDefinition->props["SendClassification"] = array("CustomerKey" => $SendClassificationCustomerKey);
 $postSendDefinition->props["SendDefinitionList"] = array("List" => array("ID" => $ListIDForSendDefinition), "DataSourceTypeID" => "List");
 $postSendDefinition->props["Email"] = array("ID" => $EmailIDForSendDefinition);
 $postResult = $postSendDefinition->post();
 print_r('Post Status: ' . ($postResult->status ? 'true' : 'false') . "\n");
 print 'Code: ' . $postResult->code . "\n";
 print 'Message: ' . $postResult->message . "\n";
 print 'Results Length: ' . count($postResult->results) . "\n";
 print 'Results: ' . "\n";
 print_r($postResult->results);
 print "\n---------------\n";
 print "Send SendDefinition \n";
 $sendSendDefinition = new ET_Email_SendDefinition();
 $sendSendDefinition->authStub = $myclient;
 $sendSendDefinition->props = array("CustomerKey" => $NewSendDefinitionName);
 $sendResponse = $sendSendDefinition->send();
 print_r('Send Status: ' . ($sendResponse->status ? 'true' : 'false') . "\n");
 print 'Code: ' . $sendResponse->code . "\n";
 print 'Message: ' . $sendResponse->message . "\n";
 print 'Results Length: ' . count($sendResponse->results) . "\n";
 print 'Results: ' . "\n";
 print_r($sendResponse->results);
 print "\n---------------\n";
 print "Check Status using the same instance of ET_Email::SendDefinition as used with start method \n";
 $emailStatus = "";
 while ($sendResponse->status && $emailStatus != "Canceled" && $emailStatus != "Complete") {
     print "Checking status in loop \n";
     # Wait a bit before checking the status to give it time to process
     sleep(15);
     $statusResponse = $sendSendDefinition->status();
     print_r('Send Status: ' . ($statusResponse->status ? 'true' : 'false') . "\n");
コード例 #2
0
ファイル: ET_Client.php プロジェクト: davidfallon/FuelSDK-PHP
 function SendEmailToDataExtension($emailID, $sendableDataExtensionCustomerKey, $sendClassficationCustomerKey)
 {
     $email = new ET_Email_SendDefinition();
     $email->props = array("Name" => uniqid(), "CustomerKey" => uniqid(), "Description" => "Created with FuelSDK");
     $email->props["SendClassification"] = array("CustomerKey" => $sendClassficationCustomerKey);
     $email->props["SendDefinitionList"] = array("CustomerKey" => $sendableDataExtensionCustomerKey, "DataSourceTypeID" => "CustomObject");
     $email->props["Email"] = array("ID" => $emailID);
     $email->authStub = $this;
     $result = $email->post();
     if ($result->status) {
         $sendresult = $email->send();
         if ($sendresult->status) {
             $deleteresult = $email->delete();
             return $sendresult;
         } else {
             throw new Exception("Unable to send using send definition due to:" . print_r($result, true));
         }
     } else {
         throw new Exception("Unable to create send definition due to: " . print_r($result, true));
     }
 }
コード例 #3
0
 /**
  * Sends email to ET using a Data Extension
  * @param $email Email ID
  * @param bool|false $DEname Data Extension Customer Key
  * @param string $emailClassification Email Classification
  * @return bool|\ET_Perform Perform response
  * @throws \Exception
  */
 public function sendEmailToDataExtension($email, $publicationListID, $DEname = false, $emailClassification = "Default Commercial", $properties = [])
 {
     $SendClassificationCustomerKey = $emailClassification;
     $EmailIDForSendDefinition = $email;
     $sd = new \ET_Email_SendDefinition();
     $sd->authStub = $this->fuel;
     $sd->props = array('Name' => uniqid(), 'CustomerKey' => uniqid(), 'Description' => "Created with ExacttargetLaravel", 'SendClassification' => array("CustomerKey" => $SendClassificationCustomerKey), 'Email' => array("ID" => $EmailIDForSendDefinition));
     $allowed_properties = ['SenderProfile', 'DeliveryProfile'];
     foreach ($properties as $key => $property) {
         if (in_array($key, $allowed_properties)) {
             $sd->props[$key] = $property;
         }
     }
     if ($DEname) {
         $sd->props["SendDefinitionList"] = array("CustomerKey" => $DEname, 'List' => array('ID' => $publicationListID, 'IDSpecified' => true), "DataSourceTypeID" => "CustomObject");
     }
     $getRes = $sd->post();
     //$getRes = $this->fuel->SendEmailToDataExtension($email, $DEname, $emailClassification);
     if ($getRes->status == 'true') {
         $res_send = $sd->send();
         Log::debug('sendEmailToDataExtension', [$res_send]);
         return $res_send;
     } else {
         Log::error('Error creating ET email(createSendDefinition)', [$getRes]);
         return false;
     }
 }