0

I'm going to get the source code for the following page.

http://www.yjc.ir/fa/rss/allnews

i run this code im my server :

$opts = [
"http" => array(
    "method" => "GET",
    "header" => "Accept-language: en\r\n" .
        "Cookie: foo=bar\r\n"
   )
];
$context = stream_context_create($opts);
echo $file = file_get_contents('http://www.yjc.ir/fa/rss/allnews', false, $context);

but gets source code As below :

source code screenshot

this page when i run in browser is correct. but when by file_get_contents or curl get is incorrect.

please help me. thank you

chris85
  • 23,846
  • 7
  • 34
  • 51
ali
  • 1
  • Looks like an encoding issue, maybe take a look at https://stackoverflow.com/questions/2236668/file-get-contents-breaks-up-utf-8-characters – chris85 Aug 22 '17 at 16:06
  • 1
    I ran a curl on that and without specifying any headers I get a `Content-Encoding: gzip` header in the response. The content is probably gzipped, however that's just bad practice on the server end to always send gzipped content whether the `Accept-Encoding` header is there or not – apokryfos Aug 22 '17 at 16:17
  • @ali try https://stackoverflow.com/questions/18206845/file-get-contents-equivalent-for-gzipped-files – alexyorke Aug 22 '17 at 17:01

0 Answers0