ID = $id; $data = array_change_key_case($data, CASE_UPPER); $finalData = []; $refl = new \ReflectionClass(__CLASS__); $constants = $refl->getConstants(); foreach ( $constants as $constName => $constValue ) { foreach ($data as $key => $value) { if ( $constName == $key ) { $finalData[$constValue] = $value; break; } } } $finalData['NAME'] = $finalData[self::CLIENT_FIRST_NAME] . ' ' . $finalData[self::CLIENT_SECOND_NAME]; $this->data = $finalData; return; } public function send() { $postdata = http_build_query( [ 'IBLOCK_TYPE_ID' => $this->IBLOCK_TYPE_ID, 'IBLOCK_ID' => $this->IBLOCK_ID, 'ELEMENT_CODE' => $this->ID, 'FIELDS' => $this->data ] ); $opts = array( 'ssl' => array( 'verify_peer' => false, 'verify_peername' => false ), 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n". '', 'content' => $postdata ) ); return true; try { $context = stream_context_create($opts); $result = file_get_contents($this->URL, false, $context); $result = json_decode($result, $associative = true); if (array_key_exists('result', $result)) { return $result['result']; } else { return false; } } catch (\Exception $e) { dd($e); return false; } } }