celd / opml-import-export
Library for importing and exporting OPML documents for list of (RSS/Atom) feeds.
Installs: 1 454
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 5
Open Issues: 1
Requires
- php: >=5.3.3
- symfony/serializer: 2.*
This package is not auto-updated.
Last update: 2024-11-19 02:20:10 UTC
README
Import/export feed lists in OPML format.
Install
Install using composer.
Import OPML file:
<?php use Celd\Opml\Importer; $importer = new Importer(file_get_contents('http://opml-url')); $feedList = $importer->getFeedList(); foreach ($feedList->getItems() as $item) { if ($item->getType() == 'category') { echo $item->getTitle(); // Category title foreach($item->getFeeds() as $feed) { echo $feed->getTitle() . "\n"; } } echo $item->getTitle(); //Root feed title } // Properties of Model/Feed are: // title, xmlUrl, htmlUrl, type (rss/atom/etc)
Exporting OPML file
<?php use Celd\Opml\Importer; use Celd\Opml\Model\FeedList; use Celd\Opml\Model\Feeed; $feedList = new FeedList(); $feed = new Feed(); $feed->setTitle('Feed title'); $feed->setXmlUrl('http://rss-feed-url'); $feed->setType('rss'); $feed->setHtmlUrl('http://html-url'); $feedList->addItem($feed); $importer = new Importer(); echo $importer->export($feedList);