function
upsert_users()
{
try {
$recordsArray = [
"data" => [
"First_Name" =>
"fname",
"Name" =>
"lname",
"Phone_number" =>
"+14055555555",
"Account_Created_Date" =>
"42-15-2015",
"User_Status" =>
"active inactive",
"User_Login_Type" =>
"0 form website 1 from fb 2 from gp",
"User_Description" =>
"about the user description",
"User_Skills" =>
"handyman plumber",
"User_Future_Skills" =>
"newskills booking taxservice",
"User_Address" =>
"142 hallow st",
"User_Other_Address" =>
"apt 111",
"User_City" =>
"plano",
"User_State" =>
"TX",
"User_ZipCode" =>
"75034",
"User_Degree" =>
"Bachelors",
'User_Institute' =>
"East Central University",
"User_Account_Type" =>
"1 for the provider and 2 for the consumer",
"User_Coupon_Code" =>
"PLANO2018",
"User_School" =>
"Newman Elementary",
"User_Where_Did_You_Hear_About_Us" =>
"links/friends",
"User_Last_Logged_In_Date" =>
"4-29-2019",
"User_Twitter_Verify" =>
"0/1",
"User_Instagram_Verify" =>
"0/1",
"User_LinkedIn_Verify" =>
"0/1",
"User_Facebook_Verify" =>
"0/1",
"User_Google_Verify" =>
"0/1",
"Record_Image" =>
"./assets/images/accounting.jpg",
"duplicate_check_fields" => [
"Email",
],
],
];
var_dump(
json_encode(
$recordsArray, JSON_PRETTY_PRINT));
$zcrmModuleIns =
ZCRMModule::
getInstance(
"aloovi");
$bulkAPIResponse =
$zcrmModuleIns->
upsertRecords(
json_encode(
$recordsArray));
// $recordsArray - array of ZCRMRecord instances filled with required data for upsert.
$entityResponses =
$bulkAPIResponse->
getEntityResponses();
if (
"success" ==
$entityResponse->
getStatus()) {
echo
"Status:" .
$entityResponse->
getStatus();
echo
"Message:" .
$entityResponse->
getMessage();
echo
"Code:" .
$entityResponse->
getCode();
$upsertData =
$entityResponse->
getUpsertDetails();
echo
"UPSERT_ACTION:" .
$upsertData[“action”];
echo
"UPSERT_DUPLICATE_FIELD:" .
$upsertData[“duplicate_field”];
$createdRecordInstance =
$entityResponse->
getData();
echo
"EntityID:" .
$createdRecordInstance->
getEntityId();
echo
"moduleAPIName:" .
$createdRecordInstance->
getModuleAPIName();
}
else {
vardump(
$entityResponse);
}
}
catch (
ZCRMException
$e) {
var_dump(
$e);
echo
$e->
getCode();
echo
$e->
getMessage();
echo
$e->
getExceptionCode();
}
}
upsert_users();