parseResourceXml example

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);

      if (json_last_error() !== JSON_ERROR_NONE) {
        throw new ResourceException('Error decoding oEmbed resource: ' . json_last_error_msg()$url);
      }
    }
    if (empty($data) || !is_array($data)) {
      throw new ResourceException('The oEmbed resource could not be decoded.', $url);
    }
Home | Imprint | This part of the site doesn't use cookies.