public function MediaSoundCloudStreamWrapper::getOEmbed in Media: SoundCloud 7
1 call to MediaSoundCloudStreamWrapper::getOEmbed()
File
- includes/
MediaSoundCloudStreamWrapper.inc, line 83 - Create a SoundCloud Stream Wrapper class for the Media/Resource module.
Class
- MediaSoundCloudStreamWrapper
- Create an instance like this: $soundcloud = new ResourceSoundCloudStreamWrapper('soundcloud://u/[user-name]/a/[audio-code]');
Code
public function getOEmbed($url, $options = array()) {
//drupal_set_message("MediaSoundCloudStreamWrapper::getOEmbed");
$oembed_parameters = array_merge(array(
'url' => $url,
'format' => 'json',
), $options);
$oembed_url = url('http://soundcloud.com/oembed', array(
'query' => $oembed_parameters,
));
//drupal_set_message(print_r($oembed_url,true));
$response = drupal_http_request($oembed_url);
//drupal_set_message(print_r($response,true));
if (!isset($response->error)) {
return drupal_json_decode($response->data);
}
else {
$error_msg = t("Error Embedding SoundCloud Media '@file'. Error code(@code) : !message", array(
'@file' => $url,
'@code' => $response->code,
'!message' => $response->status_message,
));
// Output error to watchdog
watchdog('Media Soundcloud', $error_msg, NULL, WATCHDOG_WARNING);
// Output error to admin
if (user_access('edit media')) {
drupal_set_message($error_msg, "error", FALSE);
drupal_set_message(t('Please check sharing permissions'), 'error', FALSE);
}
}
}