FeedBundle icon indicating copy to clipboard operation
FeedBundle copied to clipboard

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

Open robertfausk opened this issue 4 years ago • 3 comments
trafficstars

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 avatar Oct 11 '21 15:10 robertfausk

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.

robertfausk avatar Oct 12 '21 09:10 robertfausk

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

eko avatar Oct 12 '21 09:10 eko

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.

pueppiblue avatar Oct 15 '21 22:10 pueppiblue