How to config AUTO UPDATE exchange rate in ECBcoverter.php

Started by constatine, June 13, 2013, 12:19:01 PM

Previous topic - Next topic

constatine

Hi all.
I have one serious problem about configuration auto update exchange rate in ECBconverter

I'm Vietnamese and I want to add Vietnamese Dong rate to Currency converter.
I use file XML from Joint Stock Commercial Bank for Foreign Trade of Vietnam (Vietcombank) to convert EUR to VND
http://www.vietcombank.com.vn/ExchangeRates/ExrateXML.aspx

Before, I used Virtuemart 1.x and add more code in ECBconverter.php. So, it ok. No problem.

       
                    // now write new file
                    file_put_contents( $archivefile_name, $contents );
                }


              //code get exchange rate from vietcombank
                $Link = new SimpleXMLElement('http://www.vietcombank.com.vn/ExchangeRates/ExrateXML.aspx',NULL,true);
                foreach($Link->Exrate as $Exrate)
                {
                if ($Exrate['CurrencyCode']=="EUR") $tigia = $Exrate['Sell'];
                }
                //Add exchange rate VND-EUR into xml file
                $contents = str_replace ("<Cube currency='USD'", " <Cube currency='EUR' rate='1'/><Cube currency='VND' rate='".$tigia."'/> <Cube currency='USD'", $contents);


               
                /* XML Parsing */


But, now using Virtuemart 2.x.
I add this code into ECBconverter.php
It doesn't work ! I don't know why ?

               // now write new file
               file_put_contents( $archivefile_name, $contents );
            }


        //code get exchange rate from vietcombank
                $Link = new SimpleXMLElement('http://www.vietcombank.com.vn/ExchangeRates/ExrateXML.aspx',NULL,true);
                foreach($Link->Exrate as $Exrate)
                {
                if ($Exrate['CurrencyCode']=="EUR") $tigia = $Exrate['Sell'];
                }
                //Add exchange rate VND-EUR into xml file
                $contents = str_replace ("<Cube currency='USD'", " <Cube currency='EUR' rate='1'/><Cube Currency='VND' rate='".$tigia."'/> <Cube currency='USD'", $contents);




            /* XML Parsing */


Somebody help me :( I very very need your helps !
Thanks all.