Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
const B24_API_KEY = 'qwerty12345'; const DOMAIN = 'domian'; class Bitrix { public function __construct(){} public function leadAdd($arData){ $queryUrl = "https://".DOMAIN.".bitrix24.ru/rest/227/".B24_API_KEY."/crm.lead.add/"; $queryData = http_build_query( array( 'fields' => array( 'NAME' => $arData['NAME'] ?? '', 'PHONE' => Array(Array( 'VALUE' => $arData['PHONE_WORK'] ?? '', 'VALUE_TYPE' => 'MOBILE' )), 'EMAIL' => Array(Array( 'VALUE' => $arData['EMAIL_WORK'] ?? '', 'VALUE_TYPE' => 'MOBILE' )), 'COMMENTS' => $arData['COMMENTS'] ?? '', 'UTM_SOURCE' => $_COOKIE['utm_source'] ?? '', 'UTM_MEDIUM' => $_COOKIE['utm_medium'] ?? '', 'UTM_CAMPAIGN' => $_COOKIE['utm_campaign'] ?? '', 'UTM_CONTENT' => $_COOKIE['utm_content'] ?? '', 'UTM_TERM' => $_COOKIE['utm_term'] ?? '', 'SOURCE_ID' => 'WEB', 'TITLE' => $arData['TITLE'] ?? 'Заявка', ), 'params' => array( 'REGISTER_SONET_EVENT' => 'Y' ) ) ); return $this->sendQuery($queryUrl, $queryData); } protected function sendQuery($queryUrl, $queryData){ $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $queryUrl, CURLOPT_POSTFIELDS => $queryData, ) ); $result = curl_exec($curl); curl_close($curl); return json_decode($result, 1); } }