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


<?php
$url = 'http://api.v4.swiftreach.com/api/ContactLists/Contacts/Create/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":[] 
}';

$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 -->
<string>22748f25-07b8-459c-bcef-ce2ba851a84c</string>