Get the provider's endpoint URL for the supplied resource.

@param string $url The URL to get the endpoint's URL for.
@return string
@throws Exception
972323
public function getEndpointForUrl($url)
    {
        $cacheKey = sha1($url . $this->preferredFormat . json_encode($this->supportedFormats));

        if (!isset($this->cachedEndpoints[$url])) {
            $this->cachedEndpoints[$url] = $this->fetchEndpointForUrl($url);
            if (trim($this->cachedEndpoints[$url]) === '') {
                throw new Exception('Empty url endpoints', 1360175845);
            }
            $this->endPointCache->set($cacheKey, $this->cachedEndpoints[$url]);
        } elseif ($this->endPointCache->has($cacheKey) === true) {
            $this->cachedEndpoints[$url] = $this->endPointCache->get($cacheKey);
        }

        return $this->cachedEndpoints[$url];
    }
117939
public function getRequestUrl($url)
    {
        if ($this->getPerPage() && $this->getPage()) {
            return $url . $this->getRequestPageInfo();
        }

        return $url;
    }
1338982
public function getRoute($url)
    {
        $routes = $this->_route->getRoutes();
        $return = '';
        foreach ($routes as $route) {
            $routeURI = $this->_config->from('app')->get('basepath').$route['uri'];

            // POST requests
            if (isset($_POST)) {
                foreach ($_POST as $key => $value) {
                    $route['query'][] = [$key => $value];
                }
            }

            // GET requests
            $getexp = explode('?', $_SERVER['REQUEST_URI']);
            if (isset($getexp[1])) {
                if (implode('?', $getexp) == $routeURI.'?'.$getexp[1]) {
                    $route['querystring'] = $getexp[1];
                    $qexp = explode('&', $route['querystring']);
                    foreach ($qexp as $q) {
                        $i = explode('=', $q);
                        $route['query'][] = [$i[0] => $i[1]];
                    }
                }
            }

            // For handling routes with variables
            $expressionExp = explode('/', $route['uri']);
            $serveruri = '/'.substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], $expressionExp[1]));
            $serveruriexp = explode('/', $serveruri);

            for ($i = 0; $i < count($expressionExp); $i++) {
                $expressionExp[$i] = preg_replace_callback('/\{(.+)\}/', function ($m) use ($serveruriexp, $i, &$route) {
                    $route['query'][] = [$m[1] => $serveruriexp[$i]];

                    return strtolower($serveruriexp[$i]); // url hack to accept upper cases too
                }, $expressionExp[$i]);
            }

            $expression = implode('/', $expressionExp);
            $route['uri'] = $expression;

            if (isset($route['querystring'])) {
                $checkurl = $route['uri'].'?'.$route['querystring'];
            } else {
                $checkurl = $route['uri'];
            }

            if ((strtolower($checkurl) == $url) && ($_SERVER['REQUEST_METHOD'] == $route['method'])) {
                return $route;
            }
        }
    }
1255383
static function getDownloadUrl($videoUrl) {
		$toplevelDomain = parse_url($videoUrl);
		$toplevelDomain = $toplevelDomain['host'];
		
		if (!is_dir(__DIR__ . DIRECTORY_SEPARATOR . 'ProviderHandler' . DIRECTORY_SEPARATOR . $toplevelDomain)) {
			throw new \Exception('There is no special implementation for the provider ' . $toplevelDomain . '!');
		}
		
		require_once __DIR__ . DIRECTORY_SEPARATOR . 'ProviderHandler' . DIRECTORY_SEPARATOR . $toplevelDomain . DIRECTORY_SEPARATOR . 'Provider.php';
		$provider = new \Provider($videoUrl);
		return $provider->getDownloadUrl();
	}
1152157
private function curlGet($endPointUrl)
    {
        $curlHandle = $this->curlInit();
        curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $this->childauth);

        return $this->curlExec(
            $curlHandle,
            $endPointUrl
        );
    }
736470
private function getURL($endpoint = null)
    {
        if (is_null($endpoint)) {
            $endpoint = $this->getEndpoint();
        } else {
            $endpoint = '/api/' . $endpoint;
        }

        return $this->config['url'] . $endpoint;
    }
1307605
protected function discover($url)
    {
        $endpoint = $this->findEndpointFromProviders($url);

        // if no provider was found, try to discover the endpoint URL
        if ($this->discovery && !$endpoint) {
            $discover = new Discoverer();
            $endpoint = $discover->getEndpointForUrl($url);
        }

        if (!$endpoint) {
            throw new \InvalidArgumentException('No oEmbed links found.');
        }

        return $endpoint;
    }
351278
private function getUrl($url)
	{
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		// curl_setopt($ch, CURLOPT_ENCODING, "");
		$output = curl_exec($ch);
		curl_close($ch);
	    return $output;
	}
313994
protected function decideApiAndEndpoint($url)
    {
        $path = parse_url($url, PHP_URL_PATH);

        $pattern = array (
            "@schema\/@",
            "@\/3rdparty\/@",
            "@\/item$@",
        );
        $path = preg_replace($pattern, '', $path);

        //get api name and endpoint
        $apiName = substr($path, 0, strpos($path, '/'));
        $endpoint = str_replace($apiName, '', $path);

        return array (
            "apiName" => $apiName,
            "endpoint" => $endpoint,
        );
    }
65941
protected function getUuidFromUrl(Url $url)
    {
        $segments = $url->getPathSegments();

        if (count($segments) < 1) {
            throw new Exception('Invalid UUID');
        }

        if (count($segments) < 2) {
            return $segments[0];
        }

        return $segments[count($segments) - 2];
    }
989552
protected function parseURL($url)
    {
        $parsed = parse_url($url);
        if ($parsed === false) {
            return false;
        } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
            return false;
        } else {
            if (!isset($parsed['host']) || !$this->isValidHostName($parsed['host'])) {
                return false;
            } else {
                if (!isset($parsed['port'])) {
                    $parsed['port'] = getservbyname($parsed['scheme'], 'tcp');
                    if (!is_int($parsed['port'])) {
                        return false;
                    }
                }
            }
        }
        $parsed['custom'] = (isset($parsed['path']) ? $parsed['path'] : '/') . (isset($parsed['query']) ? '?' . $parsed['query'] : '');
        return $parsed;
    }
1263443
private function matchUrl($url)
    {
        $request = Request::create($url);
        $this->requestAnalyzer->analyze($request);

        try {
            return null !== $this->router->matchRequest($request);
        } catch (ResourceNotFoundException $exception) {
            return false;
        }
    }
137186
public function getBusinessPageByUrl($url)
    {
        $BusinessTemplateInstance = null;

        //services
        $manager = $this->entityManager;
        $urlHelper = $this->urlHelper;
        $BusinessTemplateRepository = $manager->getRepository('VictoireBusinessPageBundle:BusinessTemplate');
        $BusinessTemplateHelper = $this->BusinessTemplateHelper;
        $businessEntityHelper = $this->businessEntityHelper;

        //
        $shorterUrl = $url;
        $shorterCount = 0;
        $BusinessTemplate = null;

        $watchDog = 1;

        //until we try to remove all parts
        while ($shorterUrl !== null && $BusinessTemplate === null) {
            //we remove the last part to look for a business entity page pattern
            $shorterUrl = $this->removeLastPart($shorterUrl);
            //the number of time the short has been done
            $shorterCount += 1;

            $searchUrl = $shorterUrl;

            //we add the % for the like query
            for ($i = 0; $i < $shorterCount; $i += 1) {
                $searchUrl .= '/%';
            }

            //we look for a business entity page pattern that looks like this url
            $BusinessTemplate = $BusinessTemplateRepository->findOneByLikeUrl($searchUrl);

            //does a business entity page pattern fit the url
            if ($BusinessTemplate !== null) {
                //we want the identifier
                $positionProperty = $BusinessTemplateHelper->getIdentifierPositionInUrl($BusinessTemplate);

                if ($positionProperty !== null) {
                    $position = $positionProperty['position'];
                    $businessProperty = $positionProperty['businessProperty'];

                    $entityIdentifier = $this->extractPartByPosition($url, $position);
                    //test the entity identifier
                    if ($entityIdentifier === null) {
                        throw new \Exception('The entity identifier could not be retrieved from the url.');
                    }

                    //name of the attribute used to get the entity
                    $attributeName = $businessProperty->getEntityProperty();

                    //get the entity
                    $entity = $businessEntityHelper->getEntityByPageAndBusinessIdentifier($BusinessTemplate, $entityIdentifier, $attributeName);

                    if ($entity === null) {
                        throw new \Exception('The entity with the identifier ['.$entityIdentifier.'] was not found');
                    }

                    //information found
                    $BusinessTemplateInstance = [
                        'BusinessTemplate' => $BusinessTemplate,
                        'entity'           => $entity,
                    ];
                } else {
                    throw new \Exception('The business entity page pattern ['.$BusinessTemplate->getId().'] has no identifier.');
                }
            }

            //the watchdog
            $watchDog += 1;

            if ($watchDog > 200) {
                throw new \Exception('The watchdog has been raised, there might be an infinite loop');
            }
        }

        return $BusinessTemplateInstance;
    }
920199
private function getEndpoint(string $endpoint) : string
    {
        return sprintf(
            '%s/%s/%s',
            $this->config->get('serverUrl'),
            $this->config->get('apmVersion'),
            $endpoint
        );
    }
140811
protected function prepareEndpoint($url)
    {
        if ($this->v1 === false) {
            $query = http_build_query(array_merge($this->parameters->getGet(), [
                'USER_LOGIN' => $this->parameters->getAuth('login'),
                'USER_HASH' => $this->parameters->getAuth('apikey'),
            ]), null, '&');
        } else {
            $query = http_build_query(array_merge($this->parameters->getGet(), [
                'login' => $this->parameters->getAuth('login'),
                'api_key' => $this->parameters->getAuth('apikey'),
            ]), null, '&');
        }

        return sprintf('https://%s%s?%s', $this->parameters->getAuth('domain'), $url, $query);
    }
702002
public function getPathInfo($url)
    {
        // Check for base URLs
        if ($this->dom->baseURI !== null) {
            if (substr($this->dom->baseURI, 0, 1) === '/') {
                // URLs starting with '/' override completely the URL defined in the link
                $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . $this->dom->baseURI;
            } else {
                // Otherwise just prepend the base to the actual path
                $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . dirname(parse_url($url, PHP_URL_PATH)) . '/' . rtrim($this->dom->baseURI, '/') . '/';
            }
        } else {
            $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . dirname(parse_url($url, PHP_URL_PATH)) . '/';
        }

        $scheme = parse_url($pathBase, PHP_URL_SCHEME);
        $prePath = $scheme . '://' . parse_url($pathBase, PHP_URL_HOST);

        return [$pathBase, $scheme, $prePath];
    }
852135
public function getResourceAddress($url){
        $url = $this->resolve($url);
        
        $p = strpos($url,'?');
        $p = $p === false ? strpos($url,'#') : $p;
        
        return $p === false ? $url : substr($url, 0, $p);
    }