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");
        print 'Code: ' . $statusResponse->code . "\n";
        print 'Message: ' . $statusResponse->message . "\n";
        print 'Results Length: ' . count($statusResponse->results) . "\n";
        print 'Results: ' . "\n";
        print_r($statusResponse->results);
        print "\n---------------\n";
        $emailStatus = $statusResponse->results[0]->Status;
    }
    print "Delete SendDefinition \n";
    $deleteSendDefinition = new ET_Email_SendDefinition();
    $deleteSendDefinition->authStub = $myclient;
    $deleteSendDefinition->props = array("CustomerKey" => $NewSendDefinitionName);
    $deleteResponse = $deleteSendDefinition->delete();
    print_r('Delete Status: ' . ($deleteResponse->status ? 'true' : 'false') . "\n");
    print 'Code: ' . $deleteResponse->code . "\n";
    print 'Message: ' . $deleteResponse->message . "\n";
    print 'Results Length: ' . count($deleteResponse->results) . "\n";
    print 'Results: ' . "\n";
    print_r($deleteResponse->results);
    print "\n---------------\n";
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
Beispiel #2
0
 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));
     }
 }
 public function getSendDefinitions()
 {
     $sd = new \ET_Email_SendDefinition();
     $sd->authStub = $this->fuel;
     $sd->props = array('Name', 'Client.ID', 'CustomerKey', 'Description', 'Email.ID', 'CategoryID', 'SendDefinitionList', 'SenderProfile.CustomerKey');
     $getRes = $sd->get();
     if ($getRes->status == true) {
         return $getRes;
     } else {
         Log::error('Error retrieving (getSendDefinition)', [$getRes]);
         return false;
     }
 }