eko / FeedBundle

A Symfony bundle to build RSS feeds from your entities
http://vincent.composieux.fr
MIT License
141 stars 49 forks source link

How to use a proxy for $reader->load()? #84

Open robertfausk opened 2 years ago

robertfausk commented 2 years ago

My server has to use a proxy when reading feed. Is it possible to configure the reader to use a proxy?

Or do I have to/can I use a workaround? E.g. load the content of the feed via another library, put it into a file and use the $reader->($localFilePath)?

robertfausk commented 2 years ago

My current workaround is:

use Eko\FeedBundle\Feed\Reader;
use Goutte\Client;

$reader = new Reader();
$client = new Client();
$client->request('GET', $url);
$filename = \sprintf('%s%s%s', $this->cacheDir, \DIRECTORY_SEPARATOR, 'stellenticket.xml');
\file_put_contents($filename, $client->getInternalResponse()->getContent());
$items = $reader->load($filename);

I can provide a PR for the docs if wanted.

eko commented 2 years ago

Hi @robertfausk,

I think your workaround is the only solution available at this time.

To read feed, we are using https://github.com/laminas/laminas-feed/blob/2.16.x/src/Reader/Reader.php which does not seems to allow a proxy.

Thank you

pueppiblue commented 2 years ago

Looks like the reader allows you to set a http client Laminas\Feed\Reader::setHttpClient. We just miss a method to pass a client from Eko\FeedBundle\Feed\Reader to the laminas reader.