You are here

public function MediaInternetSoundCloudHandler::getOEmbed in Media: SoundCloud 7.2

Same name and namespace in other branches
  1. 7 includes/MediaInternetSoundCloudHandler.inc \MediaInternetSoundCloudHandler::getOEmbed()

Returns information about the media.

See http://www.oembed.com.

Return value

If oEmbed information is available, an array containing 'title', 'type', 'url', and other information as specified by the oEmbed standard. Otherwise, NULL.

1 call to MediaInternetSoundCloudHandler::getOEmbed()
MediaInternetSoundCloudHandler::getFileObject in includes/MediaInternetSoundCloudHandler.inc

File

includes/MediaInternetSoundCloudHandler.inc, line 81
Extends the MediaInternetBaseHandler class to handle SoundCloud audio.

Class

MediaInternetSoundCloudHandler
Implementation of MediaInternetBaseHandler.

Code

public function getOEmbed() {
  $uri = $this
    ->parse($this->embedCode);
  $external_url = file_create_url($uri);
  $oembed_url = url('http://soundcloud.com/oembed', array(
    'query' => array(
      'url' => $external_url,
      'format' => 'json',
    ),
  ));
  $response = drupal_http_request($oembed_url);
  if (!isset($response->error)) {
    return drupal_json_decode($response->data);
  }
  else {
    throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
    return;
  }
}