File: //www/exchange0old/cmws/samples/client-people-create.php
<?php
/* required includes */
require_once("../../exchange/Bin/constants.php");
require_once("../../exchange/Bin/init.php");
require_once(ROOT_FOLDER."Bin/Security.php");
require_once(ROOT_FOLDER."admin/classes/Model/base_actions.php");
require_once(ROOT_FOLDER."admin/classes/Model/CMSync.php");
/* SAMPLE DATA FOR NEW/EDIT PEOPLE */
$peopleArray = array(
"exchange_ref_id" => "1220700004578",
"salutation" => "Mr.",
"first_name" => "Bob",
"last_name" => "Smith",
"title" => "Director",
"former_last_name" => null,
"notes" => "Important person",
"ppsn_document_type" => "6",
"pps_number" => "XYZ298172",
"pronounced" => null,
"photo_url" => null,
"date_of_birth" => "1975-02-20",
"add_address" => 1,
"email" => array(array(
"id" => null,
"contact_for" => "Work",
"contact_value" => "dev34@credebt.com"),
array(
"id" => null,
"contact_for" => "Private",
"contact_value" => "home34@credebt.com")),
"phone" => array(array(
"id" => null,
"contact_for" => "Work",
"contact_value" => "+353 1 685-3683"),
array(
"id" => null,
"contact_for" => "Private",
"contact_value" => "+48 22 789-2378")),
"addresses" => array(array(
"id" => null,
"address_type" => "Work",
"address_1" => "15E Baggotrath Place, 15-16 Lower Baggot Street",
"address_2" => null,
"address_3" => null,
"city" => "Dublin",
"country_id" => "IE",
"postal_code" => "D02 NX49",
"state_county" => "Dublin"),
array(
"id" => null,
"address_type" => "Home",
"address_1" => "62 Lower Baggot Street",
"address_2" => null,
"address_3" => null,
"city" => "Dublin",
"country_id" => "IE",
"postal_code" => "D02 KP79",
"state_county" => "Dublin")));
/* TEST CUSTOM PHONE DATA */
$customPhoneData = array(
"phone" => array(array(
"id" => null,
"contact_for" => "Office",
"contact_value" => "+355 1 685-3683"
),
array(
"id" => null,
"contact_for" => "Home",
"contact_value" => "+49 22 789-2378"
),
array(
"id" => null,
"contact_for" => "Other",
"contact_value" => "+48 501 296-725")));
/* TEST CUSTOM EMAIL DATA */
$customEmailData = array(
"email" => array(array(
"id" => null,
"contact_for" => "Office",
"contact_value" => "dev55@credebt.com"
),
array(
"id" => null,
"contact_for" => "Other",
"contact_value" => "home55@credebt.com")));
$cmSync = new CMSync();
if (!$cmSync->cmSyncPeopleEnable) {
exit;
}
/* Test Adding New People */
$cmSync->setPeopleData($peopleArray, CM_SYNC_PEOPLE_ADD);
$cmSync->setPhoneData($customPhoneData, CM_SYNC_PEOPLE);
// $cmSync->setAddressData($customAddressData, CM_SYNC_PEOPLE);
$cmSync->setEmailData($customEmailData, CM_SYNC_PEOPLE);
$stat = $cmSync->doAddNewPeople();
if ($stat) {
$cmSync->printResponse();
} else {
echo $cmSync->getErrorMessage();
}