<!-- Intent: add an array of new contacts to a contact list with listcode of 123456
	-->


<?php
$url = 'http://api.v4.swiftreach.com/api/ContactLists/Contacts/CreateFromArray/123456';
$authToken = '123456';


$jsonString = ' 
[{ 
	"EntityName":"MyContact 0", 
	"EntityGuid":"8454e278-4e63-4ea1-a801-2c1203faf26b", 
	"Phones":[{ 
		"Phone":"2012361344", 
		"Extension":"", 
		"AnsDetectionOverride":0, 
		"OptInSMS":true, 
		"PhoneType":0, 
		"PhoneLabel":"Mobile" 
		}], 
	"Addresses":[{ 
		"AddressGuid":"b414c9e2-4501-4ab8-9dd1-4fa11ba58761", 
		"Label":"Office", 
		"Address1":"14 Industrial Ave", 
		"Address2":"", 
		"City":"Mahwah", 
		"State":"NJ", 
		"PostalCode":"07430", 
		"County":"", \ 
		"Latitude":41.052698269486427, 
		"Longitude":-74.121656566858292, 
		"IsPrimary":true 
		}], 
	"Email":"info@swiftreach.com", 
	"Fax":"", 
	"SMSPhone":"", 
	"SMSNetwork":0, 
	"Pager":"", 
	"PagerNetwork":0, 
	"PinCode":"", 
	"SpokenLanguage":"English", 
	"Tag":"", 
	"UserDefined":[] 
},{ 
	"EntityName":"MyContact 0", 
	"EntityGuid":"de4b9815-e0d1-4d53-94cd-3d3b43a0febd", 
	"Phones":[{ 
		"Phone":"2012361344", 
		"Extension":"", 
		"AnsDetectionOverride":0, 
		"OptInSMS":true, 
		"PhoneType":0,
		"PhoneLabel":"Mobile" 
		}], 
	"Addresses":[{ 
		"AddressGuid":"9c1363de-d7a8-4e0a-beca-fe3a913bf3fd", 
		"Label":"Office", 
		"Address1":"14 Industrial Ave", 
		"Address2":"", 
		"City":"Mahwah",
		"State":"NJ", 
		"PostalCode":"07430", 
		"County":"", 
		"Latitude":41.052698269486427, 
		"Longitude":-74.121656566858292, 
		"IsPrimary":true 
		}], 
	"Email":"info@swiftreach.com",  
	"Fax":"", 
	"SMSPhone":"",  
	"SMSNetwork":0, 
	"Pager":"", 
	"PagerNetwork":0, 
	"PinCode":"", 
	"SpokenLanguage":"English", 
	"Tag":"", 
	"UserDefined":[] 
}]';

$headers = array(
    'Content-type: application/json',
    'SwiftAPI-Key: ' . $authToken,
    'Accept: application/json',
    'Expect:'
);
$ch = curl_init();
$args = array(
    CURLOPT_URL => $url,
    CURLOPT_FOLLOWLOCATION => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => $jsonString,
    CURLOPT_HTTPHEADER => $headers,
);
curl_setopt_array($ch, $args);
$res = curl_exec($ch);
$res_data = json_decode($res, true);
print($res_data);
?>


<!-- example return value -->
["1335514d-a862-4457-988c-4cdec5c6bb52","d6555a27-e7ec-4b07-80a5-725d30a6de69"]