JSON request.

@param string $url
@param string|array $params
@param array $options
@param int $encodeOption

@return ResponseInterface

@throws HttpException
519164
public function json($url, $params = [], array $options, $encodeOption = JSON_UNESCAPED_UNICODE)
    {
        is_array($params) && $params = json_encode($params, $encodeOption);

        return $this->request($url, 'POST', ['body' => $options, 'headers' => ['content-type' => 'application/json']], $options);
    }
551062
protected function makeRequest($url, $options = array(), $parseJson = true) {
		$ch = $this->initRequest($url, $options);

		$result = curl_exec($ch);
		$headers = curl_getinfo($ch);

		if (curl_errno($ch) > 0) {
			throw new EAuthException(curl_error($ch), curl_errno($ch));
		}

		if ($headers['http_code'] != 200) {
			Yii::log(
				'Invalid response http code: ' . $headers['http_code'] . '.' . PHP_EOL .
					'URL: ' . $url . PHP_EOL .
					'Options: ' . var_export($options, true) . PHP_EOL .
					'Result: ' . $result,
				CLogger::LEVEL_ERROR, 'application.extensions.eauth'
			);
			throw new EAuthException(Yii::t('eauth', 'Invalid response http code: {code}.', array('{code}' => $headers['http_code'])), $headers['http_code']);
		}

		curl_close($ch);

		if ($parseJson) {
			$result = $this->parseJson($result);
		}

		return $result;
	}
846341
public function fetch($url, $options)
    {
        $this->init();

        $request_type = $this->config->http_post === true ?
            'form_params' : 'query';
        $options = [$request_type => $options];

        try {
            $response = $this->client->request(
                $this->config->http_post === true ? 'POST' : 'GET',
                $url,
                $options
            );
        } catch (GuzzleException $exception) {
            throw new ConnectionException(
                $exception->getMessage(),
                $exception->getCode()
            );
        }

        if ($response->getStatusCode() >= 400) {
            // ccp is using error codes even if they send a valid application
            // error response now, so we have to use the content as result
            // for some of the errors. This will actually break if CCP ever uses
            // the HTTP Status for an actual transport related error.
            switch ($response->getStatusCode()) {
                case 400:
                case 403:
                case 500:
                case 503:
                    return $response->getBody()->getContents();
                    break;
            }

            throw new HTTPException(
                $response->getStatusCode(),
                $url
            );
        }

        return $response->getBody()->getContents();
    }
1065759
protected function executeRequest($url, array $options = array())
    {
        $ch = curl_init($url);

        foreach ($options as $name => $value) {
            if (!curl_setopt($ch, $name, $value)) {
                if ($this->logger) {
                    $this->logger->warning("Option could not be set to Curl: $name, value: $value");
                }
            }
        }

        // some options we have to force
        curl_setopt($ch, CURLOPT_FAILONERROR, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $results = curl_exec($ch);
        if ($results === false) {
            if ($this->logger) {
                $this->logger->error("Curl request failed: " . curl_error($ch));
            }
        }

        // close cURL resource, and free up system resources
        curl_close($ch);

        return $results;
    }
360934
private function sendRequest($method, $url, array $options = [])
    {
        $response = $this->httpClient->request((string)$method, $url, $options);

        return json_decode($response->getBody(), true);
    }
781881
public function request($requestParams, $url, $method, $requiredParams, $options)
    {
        $client = $this->getHttpClient();
        $url = $this->buildEndpoint($url);

        return $client->httpRequest($requestParams, $url, $method, $requiredParams, $options);
    }
101053
public static function json( $src, $encode = 0 ) {
		$options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
		$out     = $encode ? json_encode( $src, $options ) : json_decode( $src, true );

		return $out;
	}
560282
public static function encode($value, $options = 0)
    {
        $result = json_encode($value, (int) $options);
        // @codeCoverageIgnoreStart
        if ($result === false) {
            throw new \RuntimeException(static::$errorMessages[json_last_error()]);
        }
        // @codeCoverageIgnoreEnd

        return $result;
    }
781873
protected function json_encode_options($options)
    {
        $data = $this->prepare_options($options);

        $json = json_encode($data['options']);

        $json = str_replace($data['toReplace'], $data['original'], $json);

        return $json;
    }
1300280
public function send(string $url, array $options = []): array
    {
        $response = $this->client->get($url, $options);

        $result = \GuzzleHttp\json_decode($response->getBody()->getContents(), true);
        if (!empty($result['Command']) && $result['Command'] === 'Unknown') {
            throw new UnknownCommandException('command is unknown');
        }

        return $result;
    }
205626
public function post($url, array $options = [])
    {
        return $this->responseBuilder->build($this->send(new Request('POST', $url), $options));
    }
960953
public function request($method, $url, $options)
    {
        $request = $this->authClient->getAuthenticatedRequest($method, $url, $this->getAccessToken());

        return $this->httpClient->send($request, $options);
    }
600402
protected function request($url, $curlOptions = array()) {
        // create curl instance
        $curl = curl_init($url);
        $curlOptions['url'] = $url;
        $this->resetCurlOptions();
        $this->prepareRequest($curl, $curlOptions);
        if ($this->cacheInstance && $httpbody = $this->cacheInstance->get($this->curlOptions)) {
            return $httpbody;
        } else {
            $httpbody = curl_exec($curl);
            if ($this->cacheInstance) {
                $this->cacheInstance->set($this->curlOptions, $httpbody);
            }
        }

        $this->info  = curl_getinfo($curl);
        $this->error = curl_error($curl);

        if ($this->debug){
            var_dump($this->info);
            var_dump($this->error);
        }

        curl_close($curl);

        $response = new CurlHttpResponse($this->info['http_code'], $this->responseHeaders, $httpbody);

        if (!empty($this->error)) {
            throw new \Exception($this->error);
        }
        return $response;
    }
88285
public static function doCurlJson($url, $data = null, $header = null, $option = [])
    {
        return json_decode(self::doCurl($url, $data, $header, $option), true);
    }
138019
public function sendRequest(
        MethodInterface $method,
        $requestMethod,
        $url,
        array $options = []
    ) {
        try {
            $response = $this->client->request($requestMethod, $url, $options);
            return json_decode($response->getBody(), true);
        } catch (ClientException $e) {
            throw $this->mapper->get($e, $method);
        } catch (\Exception $e) {
            throw new Exception\UnexpectedError('Unexpected error', $e->getCode(), $e);
        }
    }
1244699
public function makeSignedRequest($url, $options = [], $parseResponse = true)
	{
		$token = $this->getAccessTokenData();
		if (isset($token)) {
			$params = '';
			ksort($options['query']);
			foreach ($options['query'] as $k => $v) {
				$params .= $k . '=' . $v;
			}
			$options['query']['sig'] = md5($params . md5($token['access_token'] . $this->clientSecret));
			$options['query']['access_token'] = $token['access_token'];
		}
		return parent::makeSignedRequest($url, $options, $parseResponse);
	}
1249794
public function getRequest($method, $url, array $options = [])
    {
        return $this->createRequest($method, $url, null, $options);
    }