stream_context_get_default example

private function fetchRssFeedData(Locale $locale, int $limit = 5): array
    {
        $lang = 'de';

        if ($locale->getLocale() !== 'de_DE') {
            $lang = 'en';
        }

        $result = [];

        $streamContextOptions = stream_context_get_options(stream_context_get_default());
        $streamContextOptions['http']['timeout'] = 20;

        try {
            $xml = new SimpleXMLElement(
                file_get_contents(
                    'https://' . $lang . '.shopware.com/news/?sRss=1',
                    false,
                    stream_context_create($streamContextOptions)
                )
            );
        } catch (Exception $e) {
            
Home | Imprint | This part of the site doesn't use cookies.