user = $user; $this->showThumbnails = $showThumbnails; $this->showUploaded = $showUploaded; $this->videocount = $videocount; $this->api_version = $api_version; $this->dev_id = "1234-MYDEVID"; } function setUrl() { $h_method['on'] = "uploads"; $h_method['off'] = "favorites"; $method = $h_method[$this->showUploaded]; $this->url = "http://gdata.youtube.com/feeds/api/users/" . $this->user . "/$method" . "?max-results=" . $this->videocount; } } class MyYouTubeFaves implements apiCalls { var $user; var $showThumbnails; var $videocount; var $showUploaded; var $o_xml; var $api_version; var $dev_id; var $url; function __construct($user='lisanova', $showThumbnails, $videocount, $showUploaded='off', $api_version='1.0') { $this->user = $user; $this->showThumbnails = $showThumbnails; $this->showUploaded = $showUploaded; $this->videocount = $videocount; $this->api_version = $api_version; $this->dev_id = "1234-MYDEVID"; } // end constructor // api version 1.0 function setUrl() { $h_method['on'] = "youtube.videos.list_by_user"; $h_method['off'] = "youtube.videos.list_by_user"; $method = $h_method[$this->showUploaded]; /* if ($showUploaded == 'on') { $method = "youtube.videos.list_by_user"; } else { $method = "youtube.users.list_favorite_videos"; } */ $this->url = "http://www.youtube.com/api2_rest?method=" . "$method&" . "dev_id=" . urlencode($this->dev_id) . "&" . "user=" . $this->user; } } // end class class FaveFactory { public static function Create($user, $showThumbnails, $videocount, $showUploaded='off', $api_version) { if (strcmp($api_version, '2.0') == 0) { return new MyYouTubeFaves_2($user, $showThumbnails, $videocount, $showUploaded, $api_version); } if (strcmp($api_version, '1.0') == 0) { return new MyYouTubeFaves($user, $showThumbnails, $videocount, $showUploaded, $api_version); } } } $dynamic_fave = FaveFactory::Create("cyphgenic", 'yes', 2, 'on', '2.0'); $dynamic_fave->setUrl(); print $dynamic_fave->url . "
\n"; $dynamic_fave = FaveFactory::Create("cyphgenic", 'yes', 2, 'on', '1.0'); $dynamic_fave->setUrl(); print $dynamic_fave->url . "
\n"; ?>