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)); } }
$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"; print 'Results Length: ' . count($startResponse->results) . "\n"; print 'Results: ' . "\n"; print_r($startResponse->results); print "\n---------------\n"; if ($startResponse->status) { print "Check Status using the same instance of ET_Import as used for start\n"; $importStatus = ""; while ($importStatus != "Error" && $importStatus != "Completed") { print "Checking status in loop \n"; # Wait a bit before checking the status to give it time to process sleep(15); $statusResponse = $startImport->status();