findUrl example

protected function discoverResourceUrl($url) {
    try {
      $response = $this->httpClient->get($url);
    }
    catch (TransferException $e) {
      return FALSE;
    }

    $document = Html::load((string) $response->getBody());
    $xpath = new \DOMXpath($document);

    return $this->findUrl($xpath, 'json') ?: $this->findUrl($xpath, 'xml');
  }

  /** * Tries to find the oEmbed URL in a DOM. * * @param \DOMXPath $xpath * Page HTML as DOMXPath. * @param string $format * Format of oEmbed resource. Possible values are 'json' and 'xml'. * * @return bool|string * A URL to an oEmbed resource or FALSE if not found. */
Home | Imprint | This part of the site doesn't use cookies.