Re: Valuta árfolyamok

Zsolt Nagy nagyzsolt80 at gmail.com
2009. Sze. 10., Cs, 11:10:45 CEST


szia picit részleteznéd, h. mi micsoda?

köszi!

2009/9/10 Puskás Norbert <lista at procinet.com>

> Szia!
>
> Csak gyors copy egy működő dolgomból. Remélem segít.
>
> Bocs a csatolmányért, de itt oda a sortörés.
>
> function arfolyam()
> {
>        $bdy = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
>        $bdy.= "<soap:Envelope
> xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
> xmlns:xsd=\"http://www.w3.org/2001/XMLSchema?\"
> xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
>        $bdy.= "<soap:Body>";
>        $bdy.= "<GetCurrentExchangeRates
> xmlns=\"http://www.mnb.hu/webservices/\" />";
>        $bdy.= "</soap:Body>";
>        $bdy.= "</soap:Envelope>\r\n";
>
>        $req = "POST /arfolyamok.asmx HTTP/1.1\r\n";
>        $req.= "Host: www.mnb.hu\r\n";
>        $req.= "Connection: Close\r\n";
>        $req.= "Content-Type: text/xml; charset=utf-8\r\n";
>        $req.= "Content-Length: ".strlen($bdy)."\r\n";
>        $req.= "SOAPAction:
> \"http://www.mnb.hu/webservices/GetCurrentExchangeRates\"\r\n\r\n";
>
>        $fs = fsockopen("www.mnb.hu", 80);
>
>
>        fwrite($fs, $req.$bdy);
>
>        //fwrite($fs);
>        //$s = fgets($fs);
>
>        while (!feof($fs))
>        {
>        $s = fgets($fs);
>        $szoveg="$s";
>        }
>
>        fclose($fs);
>
>        $szoveg=str_replace("<soap:Envelope
> xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
> xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
> xmlns:xsd=\"http://www.w3.org/2001/XMLSchema
> \"><soap:Body><GetCurrentExchangeRatesResponse
> xmlns=\"http://www.mnb.hu/webservices/\"><GetCurrentExchangeRatesResult>",
> "", $szoveg);
>
>
>  $szoveg=str_replace("</GetCurrentExchangeRatesResult></GetCurrentExchangeRatesResponse></soap:Body></soap:Envelope>",
> "", $szoveg);
>
>        $szoveg=html_entity_decode($szoveg);
>
>        $xml2 = new SimpleXMLElement($szoveg);
>
>        foreach ($xml2->Day[0]->Rate as $rating) {
>        switch((string) $rating['curr']) { // Attribútum megszerzése az elem
> tömbindexeként.
>                case 'UAH':
>                $ertek['UAH']=str_replace(",", ".", $rating);
>                break;
>                case 'EUR':
>                $ertek['EUR']=str_replace(",", ".", $rating);
>                break;
>                case 'GBP':
>                $ertek['GBP']=str_replace(",", ".", $rating);
>                break;
>                case 'SEK':
>                $ertek['SEK']=str_replace(",", ".", $rating);
>                break;
>                case 'USD':
>                $ertek['USD']=str_replace(",", ".", $rating);
>                break;
>                case 'RON':
>                $ertek['RON']=str_replace(",", ".", $rating);
>                break;
>        }
>        }
>
>        $ertek['nap']=$xml2->Day["date"];
>
> return $ertek;
> }
>
> Norbi
>
> Zsolt Nagy írta:
> > Sziasztok!
> >
> > Tudna nekem valaki segíteni, hogyan lehet euró és magyar forint
> > árfolyamokat megjeleníteni egy honlapon? (olyan megoldás érdekelne ami
> > frissíti mindig magát -> a MNB lapról szedné az adatokat )
> >
> > Köszi előre is mindenkinek!
> >
> > Üdv:
> > NZS
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Techinfo mailing list
> > Techinfo at lista.sulinet.hu
> > Fel- és leiratkozás: http://lista.sulinet.hu/mailman/listinfo/techinfo
> > Illemtan: http://www.1let.hu/illemtan.html
> > Ügyfélszolgálat FAQ: http://www.kozhalo2.hu/Faq.aspx
>
>
> <?php
> function arfolyam()
> {
>        $bdy = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
>        $bdy.= "<soap:Envelope xmlns:xsi=\"
> http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"
> http://www.w3.org/2001/XMLSchema?\" xmlns:soap=\"
> http://schemas.xmlsoap.org/soap/envelope/\">";
>        $bdy.= "<soap:Body>";
>        $bdy.= "<GetCurrentExchangeRates xmlns=\"
> http://www.mnb.hu/webservices/\" />";
>        $bdy.= "</soap:Body>";
>        $bdy.= "</soap:Envelope>\r\n";
>
>        $req = "POST /arfolyamok.asmx HTTP/1.1\r\n";
>        $req.= "Host: www.mnb.hu\r\n";
>        $req.= "Connection: Close\r\n";
>        $req.= "Content-Type: text/xml; charset=utf-8\r\n";
>        $req.= "Content-Length: ".strlen($bdy)."\r\n";
>        $req.= "SOAPAction: \"
> http://www.mnb.hu/webservices/GetCurrentExchangeRates\"\r\n\r\n";
>
>        $fs = fsockopen("www.mnb.hu", 80);
>
>
>        fwrite($fs, $req.$bdy);
>
>        //fwrite($fs);
>        //$s = fgets($fs);
>
>        while (!feof($fs))
>        {
>        $s = fgets($fs);
>        $szoveg="$s";
>        }
>
>        fclose($fs);
>
>        $szoveg=str_replace("<soap:Envelope xmlns:soap=\"
> http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"
> http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"
> http://www.w3.org/2001/XMLSchema\"><soap:Body><GetCurrentExchangeRatesResponse
> xmlns=\"http://www.mnb.hu/webservices/\"><GetCurrentExchangeRatesResult>",
> "", $szoveg);
>
>
>  $szoveg=str_replace("</GetCurrentExchangeRatesResult></GetCurrentExchangeRatesResponse></soap:Body></soap:Envelope>",
> "", $szoveg);
>
>        $szoveg=html_entity_decode($szoveg);
>
>        $xml2 = new SimpleXMLElement($szoveg);
>
>        foreach ($xml2->Day[0]->Rate as $rating) {
>        switch((string) $rating['curr']) { // Attribútum megszerzése az elem
> tömbindexeként.
>                case 'UAH':
>                $ertek['UAH']=str_replace(",", ".", $rating);
>                break;
>                case 'EUR':
>                $ertek['EUR']=str_replace(",", ".", $rating);
>                break;
>                case 'GBP':
>                $ertek['GBP']=str_replace(",", ".", $rating);
>                break;
>                case 'SEK':
>                $ertek['SEK']=str_replace(",", ".", $rating);
>                break;
>                case 'USD':
>                $ertek['USD']=str_replace(",", ".", $rating);
>                break;
>                case 'RON':
>                $ertek['RON']=str_replace(",", ".", $rating);
>                break;
>        }
>        }
>
>        $ertek['nap']=$xml2->Day["date"];
>
> return $ertek;
> }
> ?>
>
> _______________________________________________
> Techinfo mailing list
> Techinfo at lista.sulinet.hu
> Fel- és leiratkozás: http://lista.sulinet.hu/mailman/listinfo/techinfo
> Illemtan: http://www.1let.hu/illemtan.html
> Ügyfélszolgálat FAQ: http://www.kozhalo2.hu/Faq.aspx
>
>
--------- következő rész ---------
Egy csatolt HTML állomány át lett konvertálva...
URL: http://lista.sulinet.hu/pipermail/techinfo/attachments/20090910/17dcfcd6/attachment.html


További információk a(z) Techinfo levelezőlistáról