Creates a signature for the given request

@param string $url     string name of url suffix
@param array  $params  array  get parameters to send to API

@return string
12530
private function createSignature($url, $params) {
    $url = $url . '?' . http_build_query($params);

    return 'giantbomb-'.substr(sha1($url), 0, 7);
  }
771894
function build($url,$params=array()) {
		$params+=$this->hive['PARAMS'];
		if (is_array($url))
			foreach ($url as &$var) {
				$var=$this->build($var,$params);
				unset($var);
			}
		else {
			$i=0;
			$url=preg_replace_callback('/@(\w+)|\*/',
				function($match) use(&$i,$params) {
					$i++;
					if (isset($match[1]) &&
						array_key_exists($match[1],$params))
						return $params[$match[1]];
					return array_key_exists($i,$params)?
						$params[$i]:
						$match[0];
				},$url);
		}
		return $url;
	}
236431
public function makeRequest($url, $params)
    {
        $http = new HttpClient('https://api.github.com');
        $res = $http->get($url, $params);

        return $res['body'];
    }
1063185
protected function build_rest_url($url, $params = array()) {
        $base = '';
        if (substr($this->_url, 0, 4) !== 'http') {
            $base .= 'http://';
        }

        $base .= $this->_url;
        if ($this->_port != 80) {
            $base .= ':' . $this->_port;
        }

        $rurl = new \Rapid\URL($base . '/api/' . $url, $params);
        return $rurl->out();
    }
360230
protected function separateUrlParams($url, $params)
    {
        $a = parse_url($url);

        if (!empty($a['query'])) {
            parse_str($a['query'], $qparts);
            $cleanParams = array();
            foreach ($qparts as $k => $v) {
                $cleanParams[$k] = $v ? $v : '';
            }
            $params   = array_merge($params, $cleanParams);
            $urlParts = explode('?', $url, 2);
            $url      = $urlParts[0];
        }

        return array($url, $params);
    }
1269138
private function createHttpGetRequest($url, array $params = [])
    {
        $url .= (count($params) > 0 ? '?' . http_build_query($params, null, '&', PHP_QUERY_RFC3986) : '');

        return new Request('GET', $url);
    }
1341499
public static function query_suffix($params)
    {
        foreach ($params as $k => $v) {
            if (is_bool($v)) {
                $params[$k] = ($v) ? 'true' : 'false';
            }
        }
        $url = http_build_query($params, null, '&');
        return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $url);
    }
483348
public function signatureD($url, $key = null, $timestamp = null, $signName = 'sign', $timeName = 't')
    {
        $key = $key ?: $this->getConfig()->get('cdn_key');
        $timestamp = dechex($timestamp ?: time());

        $parsed = parse_url($url);
        $signature = md5($key.$parsed['path'].$timestamp);
        $query = http_build_query([$signName => $signature, $timeName => $timestamp]);
        $separator = empty($parsed['query']) ? '?' : '&';

        return $url.$separator.$query;
    }
150294
private function createSignature(string $url, array $parameters): string
    {
        return 'giantbomb-'.\mb_substr(\sha1($this->buildQueryUrl($url, $parameters)), 0, 7);
    }
920792
protected function curl($url, array $params = array())
    {
        // Not using array_merge here because that function reindexes numeric keys
        $options = $params + $this->config['curl'] + array(
            CURLOPT_USERAGENT => $this->userAgent,
            CURLOPT_ENCODING => '',
            CURLOPT_FOLLOWLOCATION => true,
        );

        $options[CURLOPT_URL] = $url;
        $options[CURLOPT_HEADER] = true;
        $options[CURLOPT_RETURNTRANSFER] = 1;

         // CURLOPT_FOLLOWLOCATION doesnt play well with open_basedir/safe_mode
        if (ini_get('safe_mode') || ini_get('open_basedir')) {
            $options[CURLOPT_FOLLOWLOCATION] = false;
            $options[CURLOPT_TIMEOUT] = 15;
            $this->config['force_redirects'] = true;
        }

        $handler = curl_init();
        curl_setopt_array($handler, $options);
        $response = curl_exec($handler);

        $status = curl_getinfo($handler, CURLINFO_HTTP_CODE);
        $headerSize = curl_getinfo($handler, CURLINFO_HEADER_SIZE);

        $header = substr($response, 0, $headerSize);
        $body = substr($response, $headerSize);
        curl_close($handler);

        if ($this->config['force_redirects'] && in_array($status, array('301', '302'))) {

            if (preg_match('~(?:location|uri): ?([^\n]+)~i', $header, $matches)) {

                $url = trim($matches['1']);

                // Relative redirections
                if (substr($url, 0, 1) == '/') {
                    $parsed = parse_url($options[CURLOPT_URL]);
                    $url = $parsed['scheme'] . '://' . rtrim($parsed['host'], '/') . $url;
                }

                return $this->curl($url, $options);
            }
        }

        if (empty($body) || !in_array($status, array('200'))) {
            throw new \Exception($status . ': Invalid response for ' . $url);
        }

        return $body;
    }
931542
private function buildQueryUrl($params)
    {
        $url = parse_url($_SERVER['REQUEST_URI']);
        if (! array_key_exists('query', $url)) {
            $url['query'] = '';
        }
        parse_str($url['query'], $url['query']);
        if (! is_array($url['query'])) {
            $url['query'] = array();
        }
        // Remove 'start parameter if it exists
        if (array_key_exists('start', $url['query'])) {
            unset($url['query']['start']);
        }
        // Add extra parameters from argument
        $url['query'] = array_merge($url['query'], $params);
        $url['query'] = http_build_query($url['query']);
        $url = $url['path'] . ($url['query'] ? '?'.$url['query'] : '');
        
        return $url;
    }
1204681
private function makeUri($url, $params = array())
    {
        $uri = \GuzzleHttp\uri_template($this->endpoint, array_merge($this->defaults, $params));
        $uri = new Psr7\Uri($uri);

        // All arguments must be urlencoded (as per RFC 1738).
        $query = Psr7\build_query($params, PHP_QUERY_RFC1738);
        $uri = $uri->withQuery($query);

        return Psr7\Uri::withQueryValue($uri, 'url', $url);
    }
780771
public function sign($http_method, $url, $params, $secret) {
        $sig = array(
            strtoupper($http_method),
            preg_replace('/%7E/', '~', rawurlencode($url)),
            rawurlencode($this->get_signable_parameters($params)),
        );

        $base_string = implode('&', $sig);
        $sig = base64_encode(hash_hmac('sha1', $base_string, $secret, true));
        return $sig;
    }
1303583
public function delete($url, array $params = [])
    {
        return $this->request($this->createUrl($url), self::METHOD_DELETE, $params);
    }
1209618
public function postUrlEncoded($url, array $params)
    {
        $request = new Request(
            $url,
            'POST',
            'php://temp',
            ['content-type' => 'application/x-www-form-urlencoded']
        );

        $request->getBody()->write(http_build_query($params));
        return $this->send($request);
    }
391853
protected function buildAuthenticator($params = array())
    {
        $signature = new Signature($this->networkKey);
        $signature->getNoncer()->setLength(self::NONCE_LENGTH);

        $authenticator = array(
            'identifier' => $this->networkId,
            'time' => $signature->getRequestTime(),
            'hash' => $signature->generate($params),
            'nonce' => $signature->getNonce(),
        );

        return $authenticator;
    }
1011672
private function createLabel(array $params): string
    {
        $label = '(';
        if ($params) {
            foreach ($params as $param) {
                $label .= $param->label . ', ';
            }
            $label = substr($label, 0, -2);
        }
        $label .= ')';
        return $label;
    }