summaryrefslogtreecommitdiff
path: root/providers/Twitter.php
diff options
context:
space:
mode:
Diffstat (limited to 'providers/Twitter.php')
-rw-r--r--providers/Twitter.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/providers/Twitter.php b/providers/Twitter.php
index e9b98e1..704420e 100644
--- a/providers/Twitter.php
+++ b/providers/Twitter.php
@@ -3,6 +3,7 @@
namespace Providers;
require_once('Provider.php');
+require_once('Item.php');
require_once('../lib/codebird-php/src/codebird.php');
@@ -19,7 +20,7 @@ class Twitter extends \Providers\Provider {
}
protected function _getCachePath() {
- return '../cache/twitter.%s.json';
+ return '../cache/twitter.%s';
}
protected function _fetchItems() {
@@ -111,8 +112,25 @@ class Twitter extends \Providers\Provider {
return $content;
}
+ protected function _mapItems($content) {
+ $items = [];
+ foreach ($content as $i) {
+ $item = new Item();
+ $item->ID = $i->id_str;
+ $item->Title = $i->text;
+ $item->Link = sprintf('https://twitter.com/%s/status%s', $this->_feed, $i->id_str);
+ $item->Time = $i->created_at;
+ $item->Text = $i->text;
+ if (isset($i->user)) {
+ $item->Author = $i->user->screen_name;
+ }
+ $items[] = $item;
+ }
+ return $items;
+ }
+
protected function _sortContent($content) {
- usort($content, function($c1, $c2) { return strcmp($c2->id_str, $c1->id_str); });
+ usort($content, function($c1, $c2) { return strcmp($c2->ID, $c1->ID); });
return $content;
}