summaryrefslogtreecommitdiff
path: root/providers/Substack.php
diff options
context:
space:
mode:
Diffstat (limited to 'providers/Substack.php')
-rw-r--r--providers/Substack.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/providers/Substack.php b/providers/Substack.php
new file mode 100644
index 0000000..6dea64a
--- /dev/null
+++ b/providers/Substack.php
@@ -0,0 +1,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);
+ }
+
+}
+
+?>