Tutorial :is there a faster way to get a YouTube clip's title than this?


Currently i'm using the following, which seems quite slow for multiple clips:

static function get_yt_title($clip_id){          $feedURL = 'http://gdata.youtube.com/feeds/api/videos/' . $clip_id;      $entry = @simplexml_load_file($feedURL);      if($entry){          $video= new stdClass;          $media = $entry->children('http://search.yahoo.com/mrss/');          $video->title = ucwords(strtolower($media->group->title));          return $video->title;         }      else{          return FALSE;      }  

any more efficient methods than this for doing 5-10 clips at a time with php?



  • Get a faster server.
  • Minute, but clean your code

    static function get_yt_title($clip_id)  {      $entry = @simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $clip_id);      return ($entry) ? ucwords(strtolower($entry->children('http://search.yahoo.com/mrss/')->group->title)) : false;  }  

Use JSON Feeds: http://gdata.youtube.com/feeds/api/videos/?alt=json by appending the ?alt=json to the URI


I don't think there is. As far as i can tell this is the recommended way to get meta data like that.

There's one other thing I can think of and that is scraping the html off of youtube.com, i can almost guarantee you it isn't faster and sure as hell isn't reliable.


If you do this a lot for the same clip id's you could cache the results on your server.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »