Apologies for the vague title but am not sure how to better describe it and have been trying to work this out for hours. Have searched Google and can find no related answers and have also searched here with no luck - I may though be searching for the wrong thing.
This started with an issue over pulling an RSS feed from Bing - which works fine on other sites but on a new site that I am building it brings the news results back in German.
For these sites I am using Godady so copied the same script to other Godady hosting accounts that I have and the results from the Bing RSS feed came back in English as they should. On the new account however the news displays in German.
So after going through loads of things to eliminate what the problem may be I decided to do a simple test using file_get_contents.
On the new hosting space with nothing else in the webspace I created a php file with this in it:
<?php
$homepage = file_get_contents('https://www.bing.com/news/search?q=cars&form=YFNR&format=RSS');
echo $homepage;
?>
When I ran the above on the new account it displayed the page results in German when it should be English.
I copied the same test script above to another recent Godaddy account and it works properly and displays the results in English.
The BING URL when used in a browser displays the news in English
I have been on to Godaddy support and they have tried but I think were trying to suggest it was my script. That's why I just tried the snippet above to rule everything else out.
BTW All the hosting accounts that I am using are in the USA
So the question is what would cause a simple file_get_contents to translate the output results to a different language? Why the two different results on different accounts?
Sorry for the length of posting but hope that it explains enough - please no votes down ;-)
As you may know, Bing (and pretty much all multi-language websites) use cookies or browser setting to distribute appropriate content.
What I suspect in your situation is language setting of your hosting.
You can try to change header of your script to accept content in English:
$opts = array(
'method' => "GET",
'https'=>array(
'header'=>"Accept-language: en
"
)
);
$context = stream_context_create($opts);
$homepage = file_get_contents('https://www.bing.com/news/search?q=cars&form=YFNR&format=RSS', false, $context);
Regards,