function _oembedprovider_handle_request in oEmbed 7.0
Same name and namespace in other branches
- 8 modules/oembedprovider/oembedprovider.inc \_oembedprovider_handle_request()
- 6.0 oembedprovider.inc \_oembedprovider_handle_request()
- 7 modules/oembedprovider/oembedprovider.inc \_oembedprovider_handle_request()
Callback handler for oembed requests.
1 string reference to '_oembedprovider_handle_request'
- oembedprovider_menu in oembedprovider/
oembedprovider.module - Implements hook_menu().
File
- oembedprovider/
oembedprovider.inc, line 13 - Functions for the oEmbed provider
Code
function _oembedprovider_handle_request() {
// Check that we got a url
if (!filter_has_var(INPUT_GET, 'url')) {
return OEMBEDPROVIDER_NOT_ACCEPTABLE;
}
$url = filter_input(INPUT_GET, 'url', FILTER_VALIDATE_URL, array(
'flags' => FILTER_FLAG_PATH_REQUIRED,
));
if (empty($url)) {
return OEMBEDPROVIDER_NOT_ACCEPTABLE;
}
$parameters = array();
$input_vars = array(
'maxwidth' => FILTER_VALIDATE_INT,
'maxheight' => FILTER_VALIDATE_INT,
'view_mode' => FILTER_SANITIZE_STRING,
'langcode' => FILTER_SANITIZE_STRING,
);
foreach ($input_vars as $key => $filter) {
if (filter_has_var(INPUT_GET, $key)) {
$parameters[$key] = filter_input(INPUT_GET, $key, $filter);
}
}
if ($plugin = oembed_get_provider($url, $matches, 'provider')) {
$data = oembed_oembed_fetch($plugin, $url, $matches, $parameters);
}
if ($data) {
// Providers might include private attributes intended only for internal requests.
foreach (array_keys($data) as $key) {
if ($key[0] === '#') {
unset($data[$key]);
}
}
return _oembedprovider_result($data['type'], $data);
}
return MENU_NOT_FOUND;
}