dict = WBClass::create('WBDictionary_URL'); $this->tmp = WBClass::create('WBFile'); $this->tmp->mkdir('var/tmp/rss'); } public function readFeed( $url ) { $this->tmp->tempnam('feed'); $this->downloadFeed($url); $rss = new XML_RSS($this->tmp->realpath()); $rss->parse(); foreach( $rss->getItems() as $item ) { $this->dict->addWord($item['link']); $id = $this->dict->getId(); echo " $id " . $item['link'] . "
\n"; } unlink($this->tmp->realpath()); return true; } protected function downloadFeed($url) { $fin = WBStream::open($url, 'r'); $fout = fopen($this->tmp->realpath(), 'w'); while (!feof($fin)) { $buffer = fgets($fin, 8192); fputs($fout, $buffer, 8192); } fclose($fin); fclose($fout); } } $urls = array(); $urls[] = 'http://del.icio.us/rss/truss'; $urls[] = 'http://del.icio.us/rss/schst'; $urls[] = 'http://del.icio.us/rss/cherrykitten'; $urls[] = 'http://del.icio.us/rss/tkilla'; $urls[] = 'http://del.icio.us/rss/dotfrog'; $test = new TestDictUrl(); foreach ($urls as $url) { $test->readFeed($url); } ?>