You are here

protected function Soundcloud::oEmbed in Media entity Soundcloud 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/media/Source/Soundcloud.php \Drupal\media_entity_soundcloud\Plugin\media\Source\Soundcloud::oEmbed()

Returns oembed data for a Soundcloud url.

Parameters

string $url: The Soundcloud Url.

Return value

array An array of oembed data.

1 call to Soundcloud::oEmbed()
Soundcloud::getMetadata in src/Plugin/media/Source/Soundcloud.php
Gets the value for a metadata attribute for a given media item.

File

src/Plugin/media/Source/Soundcloud.php, line 182

Class

Soundcloud
Soundcloud entity media source.

Namespace

Drupal\media_entity_soundcloud\Plugin\media\Source

Code

protected function oEmbed($url) {
  $this->soundcloud =& drupal_static(__FUNCTION__ . hash('md5', $url));
  if (!isset($this->soundcloud)) {
    $url = 'https://soundcloud.com/oembed?format=json&url=' . $url;
    try {
      $response = $this->httpClient
        ->get($url);
      $this->soundcloud = Json::decode((string) $response
        ->getBody());
    } catch (ClientException $e) {
      $this->soundcloud = FALSE;
    }
  }
  return $this->soundcloud;
}