<?
$sTitle = htmlspecialchars($_POST["TITLE"]);
$sName = htmlspecialchars($_POST["NAME"]);
$sLastname = htmlspecialchars($_POST["LAST_NAME"]);
$sSum = htmlspecialchars($_POST["SUM"]);
$sEmail = htmlspecialchars($_POST["EMAIL"]); //почта
// $sPhone = htmlspecialchars($_POST["PHONE"]);
// $arPhone = (!empty($sPhone)) ? array(array('VALUE' => $sPhone, 'VALUE_TYPE' => 'WORK')) : array();
// $arEmail = (!empty($sEmail)) ? array(array('VALUE' => $sEmail, 'VALUE_TYPE' => 'HOME')) : array(); //взято из документации
require_once('crest.php');
$result = CRest::call('batch',
array(
'halt' => false,
'cmd'=> array(
"create_contact"=> 'crm.contact.add?fields[NAME]='.$sName.'&fields[LAST_NAME]='.$sLastname.'&fields[EMAIL]='.$sEmail, //не выводится. с arEmail тоже
"read_contact"=> 'crm.contact.get?id=$result[create_contact][ID]',
"user_deal"=> 'crm.deal.add?fields[CONTACT_ID]=$result[create_contact][ID]&fields[TITLE]='.$sTitle.'&fields[OPPORTUNITY]='.$sSum
)
)
);
&fields[EMAIL]='.$sEmail
&fields[EMAIL][0][VALUE]='.$sEmail
{
"halt": false,
"cmd": {
"create_contact": "crm.contact.add?fields[NAME]=Test&fields[LAST_NAME]=TEST&fields[EMAIL][0][VALUE]=test@mail.ru",
"read_contact": "crm.contact.get?id=$result[create_contact][ID]",
"user_lead": "crm.lead.add?fields[TITLE]=Test Assigned&fields[NAME]=$result[read_contact][NAME]&fields[CONTACT_ID]=$result[create_contact][ID]"
}
}