blob: 6dea64ac62362821259c667af7ea8d4604ca7f6d (
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
40
41
42
43
|
<?php
namespace Providers;
require_once('JsonFeed.php');
require_once('Item.php');
class Substack extends \Providers\JsonFeed {
protected function _getFeedUrl($feed) {
return sprintf('https://%s.substack.com/api/v1/posts', $feed);
}
protected function _getCachePath() {
return '../cache/substack.%s';
}
protected function _parseFeedContent($feed) {
return $feed;
}
protected function _mapItems($content) {
$items = [];
foreach ($content as $item) {
$itemObject = new Item();
$itemObject->ID = sprintf($this->feedUrl . '/' . $item->publication_id);
$itemObject->Title = strval($item->title);
$itemObject->Time = $item->post_date;
$itemObject->Text = $item->body_html;
$itemObject->Link = $item->canonical_url;
$itemObject->Author = $item->publishedByLines[0]->name;
$items[] = $itemObject;
}
return $items;
}
public function title() {
return sprintf("%s's substack", $this->_feed);
}
}
?>
|