protected function sendRequest($url, $method = 'GET', $params = [])
    {
        $request = $this->createRequest()
            ->setMethod($method)
            ->setUrl($url)
            ->setData($params);

        if ($this->verifyPeer !== null) {
            $options = [
                'sslVerifyPeer' => $this->verifyPeer
            ];
            if ($this->capath) {
                $options['sslCapath'] = $this->capath;
            }
            if ($this->cainfo) {
                $options['sslCafile'] = $this->cainfo;
            }
            $request->addOptions($options);
        }

        $response = $request->send();

        if ($method == 'HEAD') {
            $headers = [];
            foreach ($response->getHeaders()->toArray() as $name => $values) {
                $headers[strtolower($name)] = array_pop($values);
            }
            return $headers;
        }

        return $response->getContent();
    }
protected function sendRequest($url, $method = 'GET', $params = [])
    {
        $request = $this->createRequest()
            ->setMethod($method)
            ->setUrl($url)
            ->setData($params);

        if ($this->verifyPeer !== null) {
            $options = [
                'sslVerifyPeer' => $this->verifyPeer
            ];
            if ($this->capath) {
                $options['sslCapath'] = $this->capath;
            }
            if ($this->cainfo) {
                $options['sslCafile'] = $this->cainfo;
            }
            $request->addOptions($options);
        }

        $response = $request->send();

        if ($method == 'HEAD') {
            $headers = [];
            foreach ($response->getHeaders()->toArray() as $name => $values) {
                $headers[strtolower($name)] = array_pop($values);
            }
            return $headers;
        }

        return $response->getContent();
    }
protected function sendRequest ( $ url , $ method = 'GET' , $ params = [ ] ) { $ request = $ this -> createRequest ( ) -> setMethod ( $ method ) -> setUrl ( $ url ) -> setData ( $ params ) ; if ( $ this -> verifyPeer !== null ) { $ options = [ 'sslVerifyPeer' => $ this -> verifyPeer ] ; if ( $ this -> capath ) { $ options [ 'sslCapath' ] = $ this -> capath ; } if ( $ this -> cainfo ) { $ options [ 'sslCafile' ] = $ this -> cainfo ; } $ request -> addOptions ( $ options ) ; } $ response = $ request -> send ( ) ; if ( $ method == 'HEAD' ) { $ headers = [ ] ; foreach ( $ response -> getHeaders ( ) -> toArray ( ) as $ name => $ values ) { $ headers [ strtolower ( $ name ) ] = array_pop ( $ values ) ; } return $ headers ; } return $ response -> getContent ( ) ; }
Sends request to the server
@param string $url request URL.
@param string $method request method.
@param array $params request parameters.
@return array|string response.
@throws \yii\base\Exception on failure.
Sends request to the server