----------------------------------
Klasa łączy sie z youTube.com wchodzi w dany profil i pobiera filmy. Klase napisałem troszkę temu dla kolegi, a dziś robiąc porządki ją znalazłem więc zamieszczam.
<?php class youTube { public $sNick; public $sUrl = 'http://pl.youtube.com/profile_videos?user=%s'; public $sUrl_ = 'http://pl.youtube.com/profile_videos?user=%s&page=%s'; private $page; private $sString; public $aMatches_; private $bRun=false; function __construct($sNick) { $this->sNick = $sNick; } public function connect() { { } else { } } public function getVideos() { if($this->bRun) { return $this->aMatches; } else { $this->getVideos_(); return $this->aMatches; } } public function randVideo() { $aMatches_ = $this->getVideos(); return $this->aMatches_[$iKey]; } public function getVideos_() { $this->bRun = true; $this->connect(); foreach($aMatches[1] AS $sValue) { $this->aMatches_[] = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'.$aMatches__.'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'.$aMatches__.'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>'; } $this->page = preg_replace("#.*?<a href=\"/profile_videos?user=".$this->sNick."&p=r&page=([0-9]*?)\" class=\"pagerNotCurrent\">Dalej</a>.*#is", '$1', $this->sString); if((int)$this->page>0) { $this->getVideos_(); } } } ?>
I jak użyć:
<?php $yt = new youTube($sNick); ?>