Last active
February 18, 2016 09:11
-
-
Save manosriglis/0b0213c6a2aa907e38c5 to your computer and use it in GitHub Desktop.
Duplicate campaign monitor lists with custom field definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'vendor/campaignmonitor/createsend-php/csrest_lists.php'; | |
| $sourceList = new CS_REST_Lists('LIST_ID', array('api_key' => 'API_KEY')); | |
| $targetList = new CS_REST_Lists('LIST_ID', array('api_key' => 'API_KEY')); | |
| $result = $sourceList->get_custom_fields(); | |
| foreach($result->response as $field){ | |
| $fieldArray = json_decode(json_encode($field), true); | |
| if ($field->DataType == 'MultiSelectOne' || $field->DataType == 'MultiSelectMany'){ | |
| $fieldArray['Options'] = $fieldArray['FieldOptions']; | |
| unset($fieldArray['FieldOptions']); | |
| } | |
| $result = $targetList->create_custom_field($fieldArray); | |
| if ($result->was_successful()){ | |
| print "Field '".$field->FieldName."' created.\n"; | |
| }else{ | |
| print "Field '".$field->FieldName."' not created. ".$result->response->Message."\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment