function oembedprovider_deliver_response in oEmbed 7
Same name and namespace in other branches
- 8 modules/oembedprovider/oembedprovider.inc \oembedprovider_deliver_response()
- 7.0 oembedprovider/oembedprovider.inc \oembedprovider_deliver_response()
oEmbed response delivery callback.
1 string reference to 'oembedprovider_deliver_response'
- oembedprovider_menu in modules/
oembedprovider/ oembedprovider.module - Implements hook_menu().
File
- modules/
oembedprovider/ oembedprovider.inc, line 61 - Functions for the oEmbed provider
Code
function oembedprovider_deliver_response($page_callback_result) {
// Menu status constants are integers; page content is a string or array.
if (is_int($page_callback_result)) {
switch ($page_callback_result) {
case OEMBEDPROVIDER_NOT_ACCEPTABLE:
drupal_add_http_header('Status', '406 Not acceptable. The url parameter is required.');
$page_callback_result = _oembedprovider_result('link', array(
'title' => t('The URL parameter is required'),
'error' => 1,
));
break;
case MENU_NOT_FOUND:
drupal_add_http_header('Status', '404 Not found.');
$page_callback_result = _oembedprovider_result('rich', array(
'title' => t('Could not find a provider that supports this URL.'),
'error' => 1,
));
break;
}
}
$format = 'json';
if (filter_has_var(INPUT_GET, 'format')) {
$format = filter_input(INPUT_GET, 'format', FILTER_SANITIZE_STRING);
}
else {
if (arg(2)) {
$format = arg(2);
}
}
$formats = oembedprovider_formats();
if (!isset($formats[$format])) {
drupal_add_http_header('Status', '501 Not implemented. Unsupported response format "' . check_plain($format) . '"');
die;
}
drupal_add_http_header('Content-Type', $formats[$format]['mime']);
print $formats[$format]['callback']($page_callback_result);
}