summaryrefslogtreecommitdiff
path: root/providers/JsonFeed.php
blob: 2d2ed9d846432a27392935367d9bf529c13d236e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
    }

}

?>