Fetch SimplePie Feeds Through a Proxy with the cURL Backend
Supply proxy settings through SimplePie's public cURL options before feed initialization, with authentication configured for the intermediary.
First confirm SimplePie uses its default cURL fetcher: PHP's cURL extension must be available and the application must not force fsockopen. The socket fallback does not read cURL options.
For that default path, configure before init:
$feed = new \SimplePie\SimplePie();
$feed->set_feed_url('https://feeds.example/news.xml');
$feed->set_curl_options([
CURLOPT_PROXY => 'http://proxy.example:8080',
]);
$feed->init();
set_curl_options passes these values to the fetcher, so no installed File.php edit is needed. An HTTP entry from the HTTP proxy list can supply the example proxy URL for a public feed when that route is permitted and no proxy credentials are configured. For authentication, select the accepted CURLOPT_PROXYAUTH method and supply CURLOPT_PROXYUSERNAME/CURLOPT_PROXYPASSWORD. CURLOPT_HTTPAUTH serves the destination instead.
For an HTTP client injected with set_http_client, set its proxy through its own interface. Default-fetcher options cannot configure another transport. For the default cURL authentication path, see PHP cURL’s proxy-account options.
When verifying the route, distinguish a fresh fetch from a cached feed. Displaying existing items does not establish that any new download used the changed proxy.