There is a code for updating information about products from another store through the Yandex.Market file. In the beginning, I load the file with simplexml_load_file (). The site of one of the new clients is placed on the Cyrillic domain (the final link to the file is of the type 'myisayt.rf / pricelist.xml'), as a result, nothing works. Tried to translate elementary domain in punycode - does not work.

Masters, tell me how to be? Any additional libraries I can not put, because virtual hosting. Thank you in advance!

    1 answer 1

    The simplest test says that everything should work:

    <?php $xml = simplexml_load_file('https://xn----7sbb5aamccpiegbel3bh1td.xn--p1ai/sitemap.xml'); foreach ($xml->url as $line) { echo "{$line->loc}\n"; } 

    Check for a DNS error:

     var_dump(gethostbyname('xn----7sbb5aamccpiegbel3bh1td.xn--p1ai')); 

    If there is no DNS error (the command above returns the IP address), and you can download the file locally from the browser, then contact the hosting support.

    In your particular case, it seems that the server blocks requests without the User-Agent header. This is easily fixed as follows:

     <?php $file = file_get_contents('http://xn--80aaanvlco2b3a.xn--p1ai/pricelist.xml', false, stream_context_create([ 'http' => [ 'header' => 'User-Agent: PHP' ] ])); $xml = simplexml_load_string($file); var_dump($xml->shop->name); 
    • Thanks for the help, but something strange is happening. Check with the newspaper Navalny works, var_dump also returns, namely my specific file does not load. Returns false: $file = 'http://xn--80aaanvlco2b3a.xn--p1ai/pricelist.xml'; $yml_catalog = simplexml_load_file($file); $file = 'http://xn--80aaanvlco2b3a.xn--p1ai/pricelist.xml'; $yml_catalog = simplexml_load_file($file); - Ashley
    • Hidden advertising newspaper Navalny? - DaemonHK
    • @ Ashley updated the answer - sanmai