Create a new request with autorization.

@param  string  $function
@param  array   $params
@param  string  $method
@return mixed
198225
public function call($function, array $params = null, $method = 'GET')
    {
        $url = $this->endpointUrl($function);

        return $this->send($url, true, $params, $method);
    }
493044
private function createRequestPayload($method)
    {
        $this->apiUrl = $this->config['api_url'].'/'.$method;

        $this->post = $this->post->merge($this->options);
    }
390886
protected function runTemplate($method, array $params=[]) {
		ob_start();
		$result         = call_user_func_array([$this, $method], $params);
		$viewableBuffer = ob_get_clean();

		#result returned by method?
		if($result !== null) {
			if($result instanceof TemplateInterface) {
				if(!$result->getEngine() && $this->templateEngine)
					$result->setEngine($this->templateEngine);
				return $result->render();
			}
			elseif(is_numeric($result))
				return (string)$result;
			else
				return $result;
		}
		#output from method?
		elseif($viewableBuffer)
			return $viewableBuffer;
		#given view?
		elseif($this->view) {
			#given template engine?
			if($this->templateEngine)
				return $this->templateEngine->createTemplate()->render($this->view, (array)$this);
			#use the default render technique
			else
				return $this->renderDefaultTemplate($this->view, (array)$this);
		}
		#default view
		elseif($this->defaultView) {
			#given template engine?
			if($this->templateEngine) {
				$engine = $this->templateEngine;
				if($engine->templateExists($this->defaultView))
					return $engine->createTemplate()->render($this->defaultView, (array)$this);
			}
			#use the default render technique
			elseif($this->templateExists($this->defaultView))
				return $this->renderDefaultTemplate($this->defaultView, (array)$this);
		}
		#nothing to return
		return null;
	}
1269631
public function createRequest($method, $url = null, array $options = [])
    {
        $protocol_version = '1.1';
        $body = null;
        $headers = [];

        extract($options);

        $request = new Message\Request;

        $request->setMethod($method);
        $request->setUrl($url ? (string) $this->createUrl($url) : (string) $this->baseUrl);
        $request->setProtocolVersion($protocol_version);

        if (isset($body)) {
            $body = Stream::create($body);
            $request->setBody($body);
        }

        foreach ($headers as $key => $value) {
            $request->setHeader($key, $value);
        }

        return $request;
    }
65056
protected function createRequest($client, $method, $uri = '', array $parameters = [])
    {
        /**
         * @see \JonnyW\PhantomJs\Http\Request
         **/
        $request = $client->getMessageFactory()->createRequest($uri, $method);
        $request->addHeader(
            'User-Agent',
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0'
        );

        $request->addHeader(
            'Content-Type',
            'application/x-www-form-urlencoded'
        );

        if (isset($parameters['form_params'])) {
            $request->setRequestData($parameters['form_params']);
        }

        return $request;
    }
916849
public function fragment($method, array $params=[]) {
		$c = clone $this; #clone to allow nested fragments
		$c->view = null;
		$c->defaultView = $method;
		return $c->runTemplate($method, $params);
	}
946565
public function createRequest($method = 'GET', $uri = null, $headers = null, $body = null, array $options = array())
    {
        $uri = '{+base_path}/' . ltrim($uri, '/');
        if ('GET' == $method && $this->usePostMethod($uri, $options)) {
            $method = 'POST';
            $body = $options['query'];
            unset($options['query']);
        }
        return parent::createRequest($method, $uri, $headers, $body, $options);
    }
1252433
protected function performRequest($method, $path, array $params)
	{
		/* Combine given parameters with persistent parameters and convert to string values. */
		$params = array_map('strval', $params + $this->persistent_params);

		$params = $this->signRequest($path, $params, $this->getAppSecret());
		$result = $this->doRequest($method, $path, $params);

		$this->logRequest($method, $path, $params, $result);

        /* See if there were cURL errors */
        if (empty($result["body"])) {
            throw new Mollie_Exception($result["message"], $result["code"]);
        }
        $object = $this->convertResponseBodyToObject($result['body'], $result['content_type']);

        if ($object instanceof Mollie_Response) {
            $this->checkResultErrors($object);
        }

        return $object;
    }
780446
public function createRequest($method, $url, array $options = [])
    {
        $headers = isset($options['headers']) ? $options['headers'] : [];

        $body = isset($options['body']) ? $options['body'] : null;

        return new Request($method, $url, $headers, $body);
    }
560818
protected function request($url, $method, array $params = [])
    {
        curl_setopt($this->curl, CURLOPT_URL, $url);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout);

        if ($this->client !== null && $this->token !== null) {
            curl_setopt($this->curl, CURLOPT_HTTPHEADER, [
                'client: ' . $this->client,
                'token: ' . $this->token
            ]);
        } elseif ($this->apikey !== null) {
            curl_setopt($this->curl, CURLOPT_HTTPHEADER, [
                'apikey: ' . $this->apikey,
            ]);
        }

        if ($this->strictSSL === false) {
            curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, 0);
        }

        if ($method == self::METHOD_PUT || $method == self::METHOD_POST) {
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($params));
        }

        if (!$result = curl_exec($this->curl)) {
            $error = curl_error($this->curl);
            $errno = curl_errno($this->curl);
            throw new NetworkException($error, $errno);
        }

        $result = json_decode($result, true);

        return $result ? $result : [];
    }
1314034
public function request($method, $url, $params = array(), $vars = array()) {
    $this->request = curl_init();

    $this->setRequestMethod($method);
    $this->setOptions($url, $method, $params, $vars);

    $data = curl_exec($this->request);

    if ($data === false) {
      throw new \Exception('Curl Error: ' . curl_error($this->request));
    }

    $response = new HttpResponse($data);

    curl_close($this->request);

    return $response;
  }
808153
protected static function staticRequest($method, $url, $params)
    {
        $requestor = new ApiRequestor();
        list($response, $code) = $requestor->request($method, $url, $params);
        return array($response, $code);
    }
1204990
public function prepareRequest($method, array $params = [])
    {
        $request = [
            'jsonrpc' => '2.0',
            'method'  => $method,
            'id'      => mt_rand()
        ];

        $request['params'] = $params ? $params : [];

        /*$request['params'] = array_merge($request['params'], $this->params);*/
        return $request;
    }
136587
public static function create($method, array $parameters = [], $id = true) {

        $request = new RpcRequest();

        try {

            $request->setMethod($method)
                ->setParameters($parameters)
                ->setId($id);

        } catch (Exception $e) {

            throw $e;

        }

        return $request;

    }
105960
public static function fromRequest(
		$method = null,
		$url = null,
		array $params = null
	) {
		$scheme = ( !isset( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] != 'on' ) ?
			'http' : 'https';
		$url = ( $url ?: $scheme ) .
			'://' . $_SERVER['SERVER_NAME'] .
			':' .
			$_SERVER['SERVER_PORT'] .
			$_SERVER['REQUEST_URI'];
		$method = $method ?: $_SERVER['REQUEST_METHOD'];

		// We weren't handed any params, so let's find the ones relevant
		// to this request. If you run XML-RPC or similar you should use this
		// to provide your own parsed parameter-list
		if ( !$params ) {
			// Find request headers
			$headers = Util::getHeaders();

			// Parse the query-string to find GET params
			$params = Util::parseParameters( $_SERVER['QUERY_STRING'] );

			// It's a POST request of the proper content-type, so parse POST
			// params and add those overriding any duplicates from GET
			if ( $method === 'POST' &&
				isset( $headers['Content-Type'] ) &&
				strstr( $headers['Content-Type'],
					'application/x-www-form-urlencoded'
				)
			) {
				$post_data = Util::parseParameters(
					file_get_contents( self::$POST_INPUT )
				);
				$params = array_merge( $params, $post_data );
			}

			// We have a Authorization-header with OAuth data. Parse the header
			// and add those overriding any duplicates from GET or POST
			if ( isset( $headers['Authorization'] ) &&
				substr( $headers['Authorization'], 0, 6 ) === 'OAuth '
			) {
				$header_params = Util::splitHeader( $headers['Authorization'] );
				$params = array_merge( $params, $header_params );
			}
		}

		return new Request( $method, $url, $params );
	}
856730
private function buildUrl($method, $params)
    {
        $url = $this->address.$method;

        return $url."?".http_build_query($params);
    }
394983
public function request($id, $method, array $params = null)
    {
        return $this->createRequest(RequestInterface::REQUEST, array_filter([
            'jsonrpc' => self::SPEC,
            'method' => $method,
            'params' => $params,
            'id' => $id,
        ]));
    }