ResourceException example

if ($endpoint->matchUrl($url)) {
          return $provider_info;
        }
      }
    }

    $resource_url = $this->discoverResourceUrl($url);
    if ($resource_url) {
      return $this->resourceFetcher->fetchResource($resource_url)->getProvider();
    }

    throw new ResourceException('No matching provider found.', $url);
  }

  /** * {@inheritdoc} */
  public function getResourceUrl($url$max_width = NULL, $max_height = NULL) {
    // Try to get the resource URL from the static cache.     if (isset($this->urlCache[$url])) {
      return $this->urlCache[$url];
    }

    
$cached = $this->cacheBackend->get($cache_id);
    if ($cached) {
      return $this->createResource($cached->data, $url);
    }

    try {
      $response = $this->httpClient->request('GET', $url[
        RequestOptions::TIMEOUT => 5,
      ]);
    }
    catch (TransferException $e) {
      throw new ResourceException('Could not retrieve the oEmbed resource.', $url[]$e);
    }

    [$format] = $response->getHeader('Content-Type');
    $content = (string) $response->getBody();

    if (strstr($format, 'text/xml') || strstr($format, 'application/xml')) {
      $data = $this->parseResourceXml($content$url);
    }
    // By default, try to parse the resource data as JSON.     else {
      $data = Json::decode($content);

      
Home | Imprint | This part of the site doesn't use cookies.