You are here

function media_youtube_video_search in Media: YouTube 7.2

@TODO: Document this function.

1 call to media_youtube_video_search()
media_youtube_add in ./media_youtube.module
Provides a form for adding media items from YouTube search.

File

./media_youtube.module, line 369
Provides a stream wrapper and formatters appropriate for accessing and displaying YouTube videos.

Code

function media_youtube_video_search($options = array()) {
  $options['v'] = 3;
  $options['key'] = variable_get('media_youtube_api_key', '');
  $options['part'] = 'snippet';
  $options['maxResults'] = variable_get('media_youtube_max_results', '5');
  $request = drupal_http_request(url(MEDIA_YOUTUBE_REST_API, array(
    'query' => $options,
  )));
  if (!isset($request->error)) {
    $json = json_decode($request->data);
  }
  else {
    throw new Exception("Error Processing Request. (Error: {$request->code}, {$request->error}, {$request->data})");

    //if request wasn't successful, create object for return to avoid errors

    //$entry = new SimpleXMLElement();
  }

  // return media_youtube_unserialize_xml($entry);
  return $json;
}