Skip to content

Commit 9109b34

Browse files
authored
Merge pull request #80 from matriphe/add-custom-useragent-config
Add Custom User Agent from Config
2 parents 61d0890 + ba8120f commit 9109b34

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/FeedsFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ protected function configure()
102102
$this->simplePie->set_cache_duration($this->config['cache.life']);
103103
}
104104

105+
if (isset($this->config['user_agent']) && !empty($this->config['user_agent'])) {
106+
$this->simplePie->set_useragent($this->config['user_agent']);
107+
}
108+
105109
if (isset($this->config['curl.options']) && is_array($this->config['curl.options'])) {
106110
$curlOptions += $this->config['curl.options'];
107111
}

src/config/feeds.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,16 @@
102102

103103
'curl.timeout' => null,
104104

105+
/*
106+
|--------------------------------------------------------------------------
107+
| Custom User Agent
108+
|--------------------------------------------------------------------------
109+
|
110+
| Some servers block or filter request using user agent rule, this config
111+
| will help to pass it by providing custom user agent string.
112+
| Set to null to use default
113+
|
114+
*/
115+
'user_agent' => null,
116+
105117
];

0 commit comments

Comments
 (0)