function scald_youtube_search_callback in Scald YouTube 7
Callback to perform the YouTube Search.
1 string reference to 'scald_youtube_search_callback'
- scald_youtube_scald_add_form in ./
scald_youtube.module - Implements hook_scald_add_form().
File
- ./
scald_youtube.module, line 108 - Defines a YouTube provider for Scald.
Code
function scald_youtube_search_callback($form, $form_state) {
$api_key = variable_get('scald_youtube_api_key', '');
if (empty($api_key)) {
return '';
}
$q = urlencode(check_plain($form_state['values']['search_text']));
$url = SCALD_YOUTUBE_API . '/search?key=' . $api_key . '&q=' . $q . '&part=snippet&order=rating&type=video,playlist';
$response = drupal_http_request($url);
if ($response->code >= 200 && $response->code < 400 && !empty($response->data)) {
$json = json_decode($response->data);
$form['search']['search_results_wrapper']['results']['#videos'] = $json->items;
return $form['search']['search_results_wrapper'];
}
return '';
}