diff options
author | emkael <emkael@tlen.pl> | 2020-03-31 12:02:43 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2020-03-31 12:02:43 +0200 |
commit | e41ff9572d47b1507890e61b0b311ab0fd9a52fb (patch) | |
tree | 84f1a2174978dfc28b8ab68ef4cf4cfc048ba358 /providers | |
parent | 1947bb730b31933255b0d425f132ff8317b85b37 (diff) |
Tumblr provider class
Diffstat (limited to 'providers')
-rw-r--r-- | providers/Tumblr.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/providers/Tumblr.php b/providers/Tumblr.php new file mode 100644 index 0000000..680eaf6 --- /dev/null +++ b/providers/Tumblr.php @@ -0,0 +1,44 @@ +<?php + +namespace Providers; + +require_once('Rss.php'); + +class Tumblr extends \Providers\Rss { + + private $_encoding; + + protected function __getUserAgent() { + return 'Wget'; + } + + protected function _getFeedUrl($feed) { + return sprintf('https://%s.tumblr.com/rss', $feed); + } + + protected function _getCachePath() { + return '../cache/tumblr.%s'; + } + + private function __getHttpContent($feedUrl) { + $ch = curl_init($feedUrl); + curl_setopt($ch, CURLOPT_USERAGENT, $this->__getUserAgent()); + curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_ENCODING, ''); + curl_setopt($ch, CURLOPT_TIMEOUT, 20); + $page = curl_exec($ch); + curl_close ($ch); + return $page; + } + + protected function _fetchItems() { + $page = $this->__getHttpContent($this->_feedUrl); + $this->_feedXml = new \SimpleXMLElement($page); + return $this->_parseFeedContent($this->_feedXml); + } + +} + +?> |