Example #1
0
 function CreateAndStartDataExtensionImport($dataExtensionCustomerKey, $fileName, $overwrite)
 {
     $import = new ET_Import();
     $import->authStub = $this;
     $import->props = array("Name" => "SDK Generated Import " . uniqid());
     $import->props["CustomerKey"] = uniqid();
     $import->props["Description"] = "SDK Generated Import";
     $import->props["AllowErrors"] = "true";
     $import->props["DestinationObject"] = array("ObjectID" => $dataExtensionCustomerKey);
     $import->props["FieldMappingType"] = "InferFromColumnHeadings";
     $import->props["FileSpec"] = $fileName;
     $import->props["FileType"] = "CSV";
     $import->props["RetrieveFileTransferLocation"] = array("CustomerKey" => "ExactTarget Enhanced FTP");
     if ($overwrite) {
         $import->props["UpdateType"] = "Overwrite";
     } else {
         $import->props["UpdateType"] = "AddAndUpdate";
     }
     $result = $import->post();
     if ($result->status) {
         return $import->start();
     } else {
         throw new Exception("Unable to create import definition due to: " . print_r($result, true));
     }
 }
 print "\n---------------\n";
 print "Create Import to List \n";
 $postImport = new ET_Import();
 $postImport->authStub = $myclient;
 $postImport->props = array("Name" => $NewImportName);
 $postImport->props["CustomerKey"] = $NewImportName;
 $postImport->props["Description"] = "Created with RubySDK";
 $postImport->props["AllowErrors"] = "true";
 $postImport->props["DestinationObject"] = array("ID" => $ListIDForImport);
 $postImport->props["FieldMappingType"] = "InferFromColumnHeadings";
 $postImport->props["FileSpec"] = "PHPExample.csv";
 $postImport->props["FileType"] = "CSV";
 $postImport->props["Notification"] = array("ResponseType" => "email", "ResponseAddress" => "*****@*****.**");
 $postImport->props["RetrieveFileTransferLocation"] = array("CustomerKey" => "ExactTarget Enhanced FTP");
 $postImport->props["UpdateType"] = "AddAndUpdate";
 $postResponse = $postImport->post();
 print_r('Post Status: ' . ($postResponse->status ? 'true' : 'false') . "\n");
 print 'Code: ' . $postResponse->code . "\n";
 print 'Message: ' . $postResponse->message . "\n";
 print 'Results Length: ' . count($postResponse->results) . "\n";
 print 'Results: ' . "\n";
 print_r($postResponse->results);
 print "\n---------------\n";
 print "Start Import to List\n";
 $startImport = new ET_Import();
 $startImport->authStub = $myclient;
 $startImport->props = array("CustomerKey" => $NewImportName);
 $startResponse = $startImport->start();
 print_r('Start Status: ' . ($startResponse->status ? 'true' : 'false') . "\n");
 print 'Code: ' . $startResponse->code . "\n";
 print 'Message: ' . $startResponse->message . "\n";