summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--providers/XmlFeed.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/providers/XmlFeed.php b/providers/XmlFeed.php
index 0ac5e6f..1af65e2 100644
--- a/providers/XmlFeed.php
+++ b/providers/XmlFeed.php
@@ -21,8 +21,20 @@ abstract class XmlFeed extends \Providers\Provider {
abstract protected function _parseFeedContent($feed);
+ protected function _fetchFeedContent($url) {
+ $userAgent = file_get_contents('../config/user-agent');
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => "GET",
+ 'header' => "Accept: text/html,application/xml,application/xhtml+xml,text/xml\r\nAccept-Language: en;1=0.7\r\nUser-Agent: " . $userAgent,
+ ]
+ ]);
+ return trim(file_get_contents($url, FALSE, $context));
+ }
+
protected function _fetchItems() {
- $this->_feedXml = new \SimpleXMLElement($this->_feedUrl, 0, TRUE);
+ $feedContent = $this->_fetchFeedContent($this->_feedUrl);
+ $this->_feedXml = new \SimpleXMLElement($feedContent);
return $this->_parseFeedContent($this->_feedXml);
}