Example #1
0
function getFeaturedVideos()
{
    $youtube = new Services_YouTube(DEV_ID);
    $response = $youtube->listFeatured();
    if (isset($response->error)) {
        throw new Services_YouTube_Exception($response->error->description);
    }
    return $response;
}
Example #2
0
 public function testListFeatured()
 {
     try {
         $youtube = new Services_YouTube(self::DEV_ID);
         $youtube->setUseCache(true);
         $data = $youtube->listFeatured();
         $videos = $data->xpath('//video');
         $this->assertEquals(25, count($videos));
         // Array Response
         $youtube->setResponseFormat('array');
         $data = $youtube->listFeatured();
         $this->assertEquals(25, count($data['video_list']['video']));
         // XML_RPC driver
         $youtube->setDriver('xmlrpc');
         $youtube->setUseCache(false);
         $youtube->setResponseFormat('object');
         $data = $youtube->listFeatured();
         $videos = $data->xpath('//video');
         $this->assertEquals(25, count($videos));
     } catch (Services_YouTube_Exception $e) {
         print $e;
     }
 }