diff options
Diffstat (limited to 'providers/JsonFeed.php')
-rw-r--r-- | providers/JsonFeed.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/providers/JsonFeed.php b/providers/JsonFeed.php new file mode 100644 index 0000000..2d2ed9d --- /dev/null +++ b/providers/JsonFeed.php @@ -0,0 +1,39 @@ +<?php + +namespace Providers; + +require_once('Provider.php'); + +abstract class JsonFeed extends \Providers\Provider { + + protected $_feedUrl; + protected $_feedJson; + + abstract protected function _getFeedUrl($feed); + + public function __construct($feed, $options=[]) { + parent::__construct($feed, $options); + $this->_feedUrl = $this->_getFeedUrl($feed); + if (!$this->_feedUrl) { + throw new Exception('JSON feed "' . $feed . '" undefined'); + } + } + + abstract protected function _parseFeedContent($feed); + + protected function _fetchItems() { + $this->_feedJson = json_decode(file_get_contents($this->_feedUrl)); + return $this->_parseFeedContent($this->_feedJson); + } + + protected function _spamFilter($content) { + return $content; + } + + protected function _sortContent($content) { + return $content; + } + +} + +?> |