[SubstackBridge] Add Substack bridge (#4174)

* [SubstackBridge] Add Substack

* [SubstackBridge] Add docs

* [SubstackBridge] Fix lint

* [SubstackBridge] Update description

* [SubstackBridge] Update description (x2)
This commit is contained in:
Pavel Korytov 2024-07-31 22:57:20 +03:00 committed by GitHub
parent 615c533587
commit b505667168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 additions and 2 deletions

View file

@ -7,7 +7,7 @@ abstract class FeedExpander extends BridgeAbstract
{
private array $feed;
public function collectExpandableDatas(string $url, $maxItems = -1)
public function collectExpandableDatas(string $url, $maxItems = -1, $headers = [])
{
if (!$url) {
throw new \Exception('There is no $url for this RSS expander');
@ -17,7 +17,7 @@ abstract class FeedExpander extends BridgeAbstract
$maxItems = 999;
}
$accept = [MrssFormat::MIME_TYPE, AtomFormat::MIME_TYPE, '*/*'];
$httpHeaders = ['Accept: ' . implode(', ', $accept)];
$httpHeaders = array_merge(['Accept: ' . implode(', ', $accept)], $headers);
$xmlString = getContents($url, $httpHeaders);
if ($xmlString === '') {
throw new \Exception(sprintf('Unable to parse xml from `%s` because we got the empty string', $url), 10);