GET Request

@param string $url 链接地址
@param array $query 拼接在URL后的数据
@param array $data 发送的数据
@return Response|null 请求失败返回null,成功返回Response对象
973544
public function delete($url, array $query = [], array $data = [])
    {
        $url = $this->buildUrl($url, $query);
        $handle = $this->getHandler();

        curl_setopt_array($handle, [
            CURLOPT_CUSTOMREQUEST => 'DELETE',
            CURLOPT_POSTFIELDS => http_build_query($data),
        ]);

        return $this->run($handle, $url);
    }
952173
public function request($method, $url, $data = null)
    {
        $url = (string)$url;
        $data = array('$data' => $data);

        if (!$this->cache && $this->params['cache']) {
            $client_id = isset($this->params['route']['client'])
                ? $this->params['route']['client']
                : $this->params['client_id'];
            $this->cache = new Cache($client_id, $this->params['cache']);
        }

        try {
            if (!$this->server->connected) {
                if ($this->params['proxy']) {
                    $data = $this->request_proxy_data($data);
                }
                if (!$this->authed) {
                    $data['$client'] = isset($this->params['route']['client'])
                        ? $this->params['route']['client']
                        : $this->params['client_id'];
                    // Perform basic auth by default for secure/non-route based requests
                    if (!isset($this->server->options['clear']) && !isset($this->params['route']['client'])) {
                        $data['$key'] = $this->params['client_key'];
                        if ($this->cache) {
                            $data['$cached'] = $this->cache->get_versions();
                        }
                        if ($this->params['session']) {
                            $data['$session'] = $this->params['session'];
                        }
                    }
                }
                $this->server->connect();
            }
            $result = $this->server->request($method, $url, $data);
        } catch (NetworkException $e) {
            $this->request_rescue($e);
            $result = $this->server->request($method, $url, $data);
        }

        if (isset($result['$auth'])) {
            if (isset($result['$end'])) {
                // Connection ended, retry
                return $this->request($method, $url, $data['$data']);
            } else {
                $result = $this->auth($result['$auth']);
            }
        }

        return $this->response($method, $url, $data, $result);
    }
1276558
public function get($uri, $query=false)
	{
		$ch = $this->initializeRequest();

		if (is_array($query)) {
			$uri .= "?" . http_build_query($query);
		} elseif ($query) {
			$uri .= "?" . $query;
		}

		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
		curl_setopt($ch, CURLOPT_URL, $uri);
		curl_setopt($ch, CURLOPT_HTTPGET, true);
		curl_exec($ch);

		$this->checkResponse($ch);

		curl_close($ch);

		return $this;
	}
438054
public function getWithQuery(array $data, $mark = true)
    {
        if ($this->hasQuery()) {
            $url = null;

            if ($mark === true) {
                $url = '?';
            }

            $url .= http_build_query(array_merge($this->getQuery(), $data));
            $url = str_replace('%25s', '%s', $url);

            return $url;

        } else {
            return null;
        }
    }
1157693
public function getJSON($url, $query = [])
    {
        $responseBody = $this->get($url, $query, 'application/json');

        return json_decode($responseBody);
    }
868229
public function get($url, $query = [], $contentType = 'application/json')
    {
        $url = $this->buildUrl($url, $query);
        $request = $this->requestFactory->createRequest('GET', $url)
            ->withHeader('Accept', $contentType);

        $response = $this->request($request);

        return strval($response->getBody());
    }
772015
public static function postRequest($url, $data)
    {
        $url = str_replace("&amp;", "&", urldecode(trim($url)));

        $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
        $context = stream_context_create($options);

        try {
            $data = @file_get_contents($url, false, $context);
            return $data;
        } catch (\Exception $e) {
            return false;
        }
    }
888047
public function create($routeName, array $data = array(), array $query = array())
    {
        return $this->createUrl(parent::create($routeName, $data, $query));
    }
159240
public static function get($url, $query = [], $options = [])
    {
        $options['query'] = $query;
        return self::doRequest('get', $url, $options);
    }
541201
public function get($url, array $data = array(), array $extra = array())
    {
        if (!empty($data)) {
            $url = $url . '?' . http_build_query($data);
        }

		$curl = new Curl(array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => false
        ), $extra);

        return $curl->exec();
    }
16965
public function findOne($query, array $data = null) {       
        $stmt = $this->executeQuery($query, $data);   
        
        return $stmt->fetch(\PDO::FETCH_ASSOC);
    }
1169218
public function get($url, $data = array(), $dataType = null)
    {
        return $this->processMethod($url, $data, $dataType, 'GET');
    }
389819
public function getResponse(array $query = array())
    {
        $headers = $this->headers;
        $json = null;
        
        if ($this->json) {
            $json   = json_encode($query);
            $query  = array();
        }
        
        //get the authorization parameters as an array
        $signature = $this->getSignature($query);
        $authorization  = $this->getAuthorization($signature, false);
        
        //if we should use the authrization
        if ($this->useAuthorization) {
            //add the string to headers
            $headers[] = sprintf(self::AUTH_HEADER, $this->buildQuery($authorization, ',', false));
        } else {
            //merge authorization and query
            $query = array_merge($authorization, $query);
        }
        
        $query = $this->buildQuery($query);
        $url = $this->url;
        
        //set curl
        $curl = Curl::i()->verifyHost(false)->verifyPeer(false);
        
        //if post
        if ($this->method == self::POST) {
            $headers[] = self::POST_HEADER;
            
            if (!is_null($json)) {
                $query = $json;
            }
            
            //get the response
            $response = $curl->setUrl($url)
                ->setPost(true)
                ->setPostFields($query)
                ->setHeaders($headers)
                ->getResponse();
        } else {
            if (trim($query)) {
                //determine the conector
                $connector = null;
                
                //if there is no question mark
                if (strpos($url, '?') === false) {
                    $connector = '?';
                //if the redirect doesn't end with a question mark
                } else if (substr($url, -1) != '?') {
                    $connector = '&';
                }
                
                //now add the secret to the redirect
                $url .= $connector.$query;
            }
            
            //get the response
            $response = $curl->setUrl($url)->setHeaders($headers)->getResponse();
        }
        
        $this->meta = $curl->getMeta();
        $this->meta['url'] = $url;
        $this->meta['authorization'] = $authorization;
        $this->meta['headers'] = $headers;
        $this->meta['query'] = $query;
        $this->meta['response'] = $response;
        
        return $response;
    }
1169358
public static function run($url = null, $data = null, $method = 'GET') {
        if ($url) {
            if (is_string($data)) {
                $method = $data;
                $data   = null;
            }
            $method                 = strtoupper($method);
            $_SERVER['REQUEST_URI'] = $url;
            $query                  = @parse_url($url, PHP_URL_QUERY);
            if ($query) {
                $args = [];
                parse_str($query, $args);
                if ($args) {
                    if ($data) {
                        $data = array_merge($data, $args);
                    } else {
                        $data = $args;
                    }
                }
            }
            $_SERVER['REQUEST_METHOD'] = $method;
            if ($data) {
                if ($method == 'GET') {
                    $_SERVER['QUERY_STRING'] = http_build_query($data);
                }
                Request::getInstance()->addUserData($data);
            }

            $_SERVER['REQUEST_TIME'] = time();
        }
        if (!isset ($_SERVER ['REQUEST_URI'])) {
            Response::respond(500, 'Your web server did not provide REQUEST_URI, stop route request.');
        }

        if (!self::$app->router) {
            self::$app->router = Router::getRouter();
        }
        try {
            return self::$app->router->route();
        } catch (\Exception $e) {
            if (defined('DEBUG') && DEBUG < DEBUG_ERROR) {
                show_exception_page($e);
            } else {
                Response::respond(500, $e->getMessage());
            }
        }

        return false;
    }
907991
public function get($url, array $data = [])
    {
        if (count($data) > 0) {
            $this->setopt(CURLOPT_URL, $url.'?'.http_build_query($data));
        } else {
            $this->setopt(CURLOPT_URL, $url);
        }
        $this->setopt(CURLOPT_HTTPGET, true);
        $this->_exec();
    }
1108678
protected function buildUrl($url, array $data)
    {
        if (!$data) {
            return $url;
        }

        if (strpos($url, '?') === false) {
            $url .= '?';
        } elseif (substr($url, 0, -1) != '?') {
            $url .= '&';
        }

        return $url . http_build_query($data);
    }
698129
public function doQueryOne($query, $data = null)
	{
		// Prepare and execute the entered query
		$prepQuery = parent::prepare($query);
		$prepQuery->execute($data);
		
		// Since this function is only to return one row, only return the first row
		return $prepQuery->fetch();
	}