url = $url; $this->data = $data; } public function send() { $postdata = http_build_query( $this->data ); $opts = array( 'ssl' => array( 'verify_peer' => true, 'verify_peername' => true ), 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n" . '', 'content' => $postdata ) ); try { $context = stream_context_create($opts); $result = file_get_contents($this->url, false, $context); $result = json_decode($result, $associative = true); $this->resultData = $result; if (array_key_exists('result', $result)) { return $result['result']; } else { return false; } } catch (\Exception $e) { Log::build([ 'driver' => 'single', 'path' => storage_path('logs/bitrix.log'), ])->error($e->getMessage()); return false; } } }