protected function fetchEndpointForUrl($url)
    {
        $endPoint = null;

        try {
            $content = $this->browser->getContent($url);
        } catch (Exception $exception) {
            throw new Exception(
                'Unable to fetch the page body for "' . $url . '": ' . $exception->getMessage(),
                Exception::PAGE_BODY_FETCH_FAILED
            );
        }

        preg_match_all("/<link rel=\"alternate\"[^>]+>/i",
            $content,
            $out);
        if ($out[0]) {
            foreach ($out[0] as $link) {
                if (strpos($link, trim($this->preferredFormat . '+oembed')) !== false) {
                    $endPoint = $this->extractEndpointFromAttributes($link);
                    break;
                }
            }
        } else {
            throw new Exception(
                'No valid oEmbed links found on the document at "' . $url . '".',
                Exception::NO_OEMBED_LINKS_FOUND
            );
        }

        return $endPoint;
    }