Get the hash from a Guest Access URL

@param string $url
@param array $options
@return string
331371
protected function appendUrlOptions($url, $options)
    {
        $options = array_only($options, [
            'welcome_msg',
            'timezone',
            'anonymous',
            'minimal'
        ]);

        $boolean_keys = ['minimal', 'anonymous'];
        foreach ($boolean_keys as $key) {
            if (isset($options[$key])) {
                $options[$key] = $this->booleanToString($options[$key]);
            } else {
                $options[$key] = 'true';
            }
        }

        return $url . '?' . http_build_query($options);
    }
92445
public function next($nextUrl, $options = [])
    {
        $url = $this->instanceURLRepo->get();
        $url .= $nextUrl;

        $queryResults = $this->request($url, $options);

        return $queryResults;
    }
685474
protected function httpBuildQuery($url, array $options)
    {
        if (stripos($url, 'http://') === false && stripos($url, 'https://') === false) {
            $url = self::WECHAT_BASE_URL . $url;
        }
        return parent::httpBuildQuery($url, $options);
    }
191413
public static function simpleClient($url, $options = null, $transport = null) 
	{
		$options['version'] = 'simple';
		return self::client($url, $options, $transport);
	}
385311
public function getContentUrl($hash, $options = array()) {
		if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) {
			$path = $this->decode($hash);
			$cache = $this->getDBdat($path);
			$url = '';
			if (isset($cache['share']) && strpos($cache['share'], $this->dropbox_dlhost) !== false) {
				$res = $this->getHttpResponseHeader($cache['share']);
				if (preg_match("/^HTTP\/[01\.]+ ([0-9]{3})/", $res, $match)) {
					if ($match[1] < 400) {
						$url = $cache['share'];
					}
				}
			}
			if (! $url) {
				try {
					$res = $this->dropbox->share($path, null, false);
					$url = $res['url'];
					if (strpos($url, 'www.dropbox.com') === false) {
						$res = $this->getHttpResponseHeader($url);
						if (preg_match('/^location:\s*(http[^\s]+)/im', $res, $match)) {
							$url = $match[1];
						}
					}
					list($url) = explode('?', $url);
					$url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
					if (! isset($cache['share']) || $cache['share'] !== $url) {
						$cache['share'] = $url;
						$this->updateDBdat($path, $cache);
					}
				} catch (Dropbox_Exception $e) {
					return false;
				}
			}
			return $url;
		}
		return $file['url'];
	}
740640
protected function _curl($url,$options) {
		$curl=curl_init($url);
		if (!$open_basedir=ini_get('open_basedir'))
			curl_setopt($curl,CURLOPT_FOLLOWLOCATION,
				$options['follow_location']);
		curl_setopt($curl,CURLOPT_MAXREDIRS,
			$options['max_redirects']);
		curl_setopt($curl,CURLOPT_PROTOCOLS,CURLPROTO_HTTP|CURLPROTO_HTTPS);
		curl_setopt($curl,CURLOPT_REDIR_PROTOCOLS,CURLPROTO_HTTP|CURLPROTO_HTTPS);
		curl_setopt($curl,CURLOPT_CUSTOMREQUEST,$options['method']);
		if (isset($options['header']))
			curl_setopt($curl,CURLOPT_HTTPHEADER,$options['header']);
		if (isset($options['content']))
			curl_setopt($curl,CURLOPT_POSTFIELDS,$options['content']);
		if (isset($options['proxy']))
			curl_setopt($curl,CURLOPT_PROXY,$options['proxy']);
		curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');
		$timeout=isset($options['timeout'])?
			$options['timeout']:
			ini_get('default_socket_timeout');
		curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,$timeout);
		curl_setopt($curl,CURLOPT_TIMEOUT,$timeout);
		$headers=[];
		curl_setopt($curl,CURLOPT_HEADERFUNCTION,
			// Callback for response headers
			function($curl,$line) use(&$headers) {
				if ($trim=trim($line))
					$headers[]=$trim;
				return strlen($line);
			}
		);
		curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,2);
		curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);
		ob_start();
		curl_exec($curl);
		$err=curl_error($curl);
		curl_close($curl);
		$body=ob_get_clean();
		if (!$err &&
			$options['follow_location'] && $open_basedir &&
			preg_grep('/HTTP\/1\.\d 3\d{2}/',$headers) &&
			preg_match('/^Location: (.+)$/m',implode(PHP_EOL,$headers),$loc)) {
			$options['max_redirects']--;
			if($loc[1][0] == '/') {
				$parts=parse_url($url);
				$loc[1]=$parts['scheme'].'://'.$parts['host'].
					((isset($parts['port']) && !in_array($parts['port'],[80,443]))
						?':'.$parts['port']:'').$loc[1];
			}
			return $this->request($loc[1],$options);
		}
		return [
			'body'=>$body,
			'headers'=>$headers,
			'engine'=>'cURL',
			'cached'=>FALSE,
			'error'=>$err
		];
	}
30798
public function cache($url, array $options = null)
    {
        $lifetime = array_get($options, 'lifetime', 60);

        array_forget($options, 'lifetime');

        $self = $this;

        return $this->cache->remember($url, $lifetime, function() use ($self, $url, $options)
        {
			return $self->get($url, $options);
        });
    }
61182
public function request($url, $options = array())
    {
        $result = null;
        $this->hook->attach('http.request.before', $url, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $result = $this->socket->request($url, $options);
        $this->hook->attach('http.request.after', $url, $options, $result, $this);
        return $result;
    }
33040
public function getShareLink($url, array $options = array())
    {
        $options['url'] = $url;

        return sprintf(self::SHARE_URL, http_build_query($options));
    }
1020118
protected function initRequest($url, $options = array()) {
		$ch = parent::initRequest($url, $options);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
		return $ch;
	}
419492
private function buildUrl($url)
    {
        // URI template (absolute or relative)
        if (!is_array($url)) {
            return strpos($url, '://')
                ? (string) $url
                : (string) $this->baseUrl->combine($url);
        }

        if (!isset($url[1])) {
            throw new \InvalidArgumentException('You must provide a hash of '
                . 'varname options in the second element of a URL array.');
        }

        // Absolute URL
        if (strpos($url[0], '://')) {
            return Utils::uriTemplate($url[0], $url[1]);
        }

        // Combine the relative URL with the base URL
        return (string) $this->baseUrl->combine(
            Utils::uriTemplate($url[0], $url[1])
        );
    }
855181
public static function url($segments, $options = array())
    {
        $request = Router::getInstance()->request;

        $options['X-App-Id'] = Context::getKey()->app_id;
        $options['X-App-Key'] = Context::getKey()->key;

        $segments .= '?' . http_build_query($options);

        return $request->getUrl() . $request->getScriptName() . '/' . $segments;
    }
264886
public function get($url, $data = array(), $options = array())
    {
        $query = http_build_query($data);
        if (!empty($query)) {
            $url = (strpos($url, '?')) ? $url . '&' . $query : $url . '?' . $query;
        }

        $this->request($url, false, $options);

        return $this;
    }
1207135
public function getLoginUrl($options = array()) {
        $options = array_merge(array(
            'scope' => 'openid profile',
        ), $options);

        if (isset($options['scope']) && is_array($options['scope'])) {
            $options['scope'] = join(' ', $options['scope']);
        }

        // Generate nonce
        if (function_exists('openssl_random_pseudo_bytes')) {
            $nonce = sha1(openssl_random_pseudo_bytes(24));
        } else {
            $nonce = sha1(uniqid(mt_rand(), true));
        }
        $this->sessionStorage->write('nonce', $nonce);

        return $this->getUrl('oauth', 'authorize', array(
            'client_id' => $this->getClientId(),
            'response_type' => 'code',
            'scope' => $options['scope'],
            'redirect_uri' => isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirectUri,
            'nonce' => $nonce,
        ));
    }
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;
    }
965389
public function get($url, array $params = null, array $options = array())
	{
		return $this->request($url, 'GET', $params, $options);
	}
1025859
protected function exec(Url $url, array $options)
    {
        $connection = curl_init((string) $url);
        curl_setopt_array($connection, $options);

        $curl = new CurlResult($connection);

        //Get only text responses
        $curl->onHeader(function ($name, $value, $data) {
            if ($name === 'content-type') {
                $data->isBinary = !preg_match('/(text|html|json)/', strtolower($value));
            }
        });

        $curl->onBody(function ($string, stdClass $data) {
            return empty($data->isBinary);
        });

        curl_exec($connection);

        $result = $curl->getResult();

        curl_close($connection);

        return $this->responses[] = new Response(
            $url,
            Url::create($result['url']),
            $result['statusCode'],
            $result['contentType'],
            $result['content'],
            $result['headers'],
            $result['info']
        );
    }