<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19154">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>Estimados.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Aca les paso la solucion final que puede llegar a
servirles...</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Saludos.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><?php<BR><BR>function obtener_cotizacion(){<BR><BR> //
URL banco nacion<BR> $url = "<A
href="http://www.bna.com.ar/bp/bp_cotizaciones.asp?op=m"
target=_blank>http://www.bna.com.ar/bp/bp_<WBR>cotizaciones.asp?op=m</A>";<BR>
// regexp para buscar los valores<BR> $regexp =
<BR> '/<td class="linksazul"
align="center">([0-9]\.[0-9]{<WBR>3,})<\/td>/'; <BR>
// cache de n * 60 segundos, ajustable... 60 segundos en este
caso<BR> $cache_time = 1 * 60;<BR> //
archivo de cache de divisas<BR> $cache_file =
'divisas.cache.txt'; <BR><BR> if
(<BR> file_exists($cache_file) &&
<BR> time() - $cache_time <
filemtime($cache_file)<BR>
){<BR> $cache =
file_get_contents($cache_file)<WBR>;<BR>
$datos = unserialize($cache);<BR>
return $datos;<BR> } else
{<BR> $html =
file_get_contents($url);<BR> if
(preg_match_all($regexp, $html, $matches))
{<BR>
$valores['dolar_compra'] =
$matches[1][0];<BR>
$valores['dolar_venta'] =
$matches[1][1];<BR>
$valores['libra_compra'] =
$matches[1][2];<BR>
$valores['libra_venta'] =
$matches[1][3];<BR>
$valores['euro_compra'] =
$matches[1][4];<BR>
$valores['euro_venta'] =
$matches[1][5];<BR>
$serialized =
serialize($valores);<BR>
$fh = fopen($cache_file,
'w+');<BR>
if($fh){
<BR>
fwrite($fh,
$serialized);<BR>
fclose($fh);<BR>
}<BR> return
$valores;<BR> } else return
FALSE;<BR> }<BR>}<BR><BR>$divisas =
obtener_cotizacion();<BR><BR>?></DIV>
<DIV> </DIV>
<DIV>Rogelio A. Schwindt<BR>Analista de Sistemas<BR>Area informática<BR>FCA -
Balcarce<BR><A
href="mailto:agrainfo@mdp.edu.ar">agrainfo@mdp.edu.ar</A><BR>---------------------------------------------------------</DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=roger@telefax.com.ar href="mailto:roger@telefax.com.ar">Rogelio A.
Schwindt</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=cjnimes@yahoo.com.ar
href="mailto:cjnimes@yahoo.com.ar">Cristian Nimes</A> ; <A
title=php-avanzado@pato2.fi.mdp.edu.ar
href="mailto:php-avanzado@pato2.fi.mdp.edu.ar">Lista del curso de PHP
Avanzado</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, October 13, 2011 10:19
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Php-avanzado] Convertir
Moneda para Campo en Form</DIV>
<DIV><BR></DIV>
<DIV><FONT size=2 face=Arial>Gracias Cris... ahi estuve mirando y parece que
puede servirme para lo que necesito.</FONT></DIV>
<DIV><FONT size=2 face=Arial>A la tarde voy a probarla.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Muchas gracias !!!</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>Rogelio A. Schwindt<BR>Analista de Sistemas<BR>Area informática<BR>FCA -
Balcarce<BR><A
href="mailto:agrainfo@mdp.edu.ar">agrainfo@mdp.edu.ar</A><BR>---------------------------------------------------------</DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=cjnimes@yahoo.com.ar href="mailto:cjnimes@yahoo.com.ar">Cristian
Nimes</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=php-avanzado@pato2.fi.mdp.edu.ar
href="mailto:php-avanzado@pato2.fi.mdp.edu.ar">Lista del curso de PHP
Avanzado</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, October 13, 2011 9:56
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Php-avanzado] Convertir
Moneda para Campo en Form</DIV>
<DIV><BR></DIV>
<DIV
style="BACKGROUND-COLOR: #fff; FONT-FAMILY: arial, helvetica, sans-serif; COLOR: #000; FONT-SIZE: 10pt">
<DIV><SPAN>Buenasss....</SPAN></DIV>
<DIV><SPAN><BR></SPAN></DIV>
<DIV><SPAN>Fijate si te puede servir esto:</SPAN></DIV>
<DIV><SPAN><A
href="http://xurrency.com/api">http://xurrency.com/api</A><BR></SPAN></DIV>
<DIV><SPAN><BR></SPAN></DIV>
<DIV><SPAN>No lo he usado nunca, pero una vez estuve a punto de tener que
resolver algo parecido a lo tuyo y recuerdo haber considerado esa
API.<BR></SPAN></DIV>
<DIV><SPAN><BR></SPAN></DIV>
<DIV><SPAN>Saludos.<BR></SPAN></DIV>
<DIV><BR></DIV>
<DIV style="FONT-FAMILY: 'arial', 'helvetica', sans-serif; FONT-SIZE: 10pt">
<DIV
style="FONT-FAMILY: 'times new roman', 'new york', 'times', serif; FONT-SIZE: 12pt"><FONT
size=2 face=Arial>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">De:</SPAN></B> unes pacio <<A
href="mailto:unespac@gmail.com">unespac@gmail.com</A>><BR><B><SPAN
style="FONT-WEIGHT: bold">Para:</SPAN></B> Lista del curso de PHP Avanzado
<<A
href="mailto:php-avanzado@pato2.fi.mdp.edu.ar">php-avanzado@pato2.fi.mdp.edu.ar</A>><BR><B><SPAN
style="FONT-WEIGHT: bold">Enviado:</SPAN></B> jueves, 13 de octubre de 2011
9:21<BR><B><SPAN style="FONT-WEIGHT: bold">Asunto:</SPAN></B> Re:
[Php-avanzado] Convertir Moneda para Campo en Form<BR></FONT><BR>
<DIV id=yiv1428594808>Buenas Roger, si no tenes alguna api que te de el
valor del dolar directamente, podes usar curl para cargar el codigo html de
la página y despues parsearlo buscando con una expresion regular algo asi
<DIV><td xxxxxxxxxx>Dolar</td><td
xxxxxxxxxxxx>n.nnn</td><td xxxxxxxx>n.nnn</td></DIV>
<DIV>lo metes en una variable y haces lo que se te antoje. Salu2
<DIV><BR></DIV>
<DIV>PD: yo pondria que esto lo haga una vez al dia y lo guarde en un
archivo para mejorar el tiempo de respuesta</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR><BR>
<DIV class=yiv1428594808gmail_quote>El 13 de octubre de 2011 08:37, Rogelio
A. Schwindt <SPAN dir=ltr><<A href="mailto:roger@telefax.com.ar"
rel=nofollow target=_blank
ymailto="mailto:roger@telefax.com.ar">roger@telefax.com.ar</A>></SPAN>
escribió:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=yiv1428594808gmail_quote>
<DIV>
<DIV><FONT size=2 face=Arial>Hola.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>Para un formulario de pago online estoy
necesitando que el valor de uno de los campos se rellene automaticamente
con el valor de:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> X * cotizacion del dolar tipo venta del
banco Nacion Arg. (<A
href="http://www.bna.com.ar/bp/bp_cotizaciones.asp?op=m" rel=nofollow
target=_blank>http://www.bna.com.ar/bp/bp_cotizaciones.asp?op=m</A>)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>Alguno tiene implementado algo similar o
algun ejemplo?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>Gracias.</FONT></DIV>
<DIV> </DIV><FONT color=#888888>
<DIV>Rogelio A.
Schwindt<BR></DIV></FONT></DIV><BR>_______________________________________________<BR>Php-avanzado
mailing list<BR><A href="mailto:Php-avanzado@pato2.fi.mdp.edu.ar"
rel=nofollow target=_blank
ymailto="mailto:Php-avanzado@pato2.fi.mdp.edu.ar">Php-avanzado@pato2.fi.mdp.edu.ar</A><BR><A
href="http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado"
rel=nofollow
target=_blank>http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado</A><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV><BR>_______________________________________________<BR>Php-avanzado
mailing list<BR><A href="mailto:Php-avanzado@pato2.fi.mdp.edu.ar"
ymailto="mailto:Php-avanzado@pato2.fi.mdp.edu.ar">Php-avanzado@pato2.fi.mdp.edu.ar</A><BR><A
href="http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado"
target=_blank>http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado</A><BR><BR></DIV></DIV></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Php-avanzado
mailing
list<BR>Php-avanzado@pato2.fi.mdp.edu.ar<BR>http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado</BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>Php-avanzado mailing
list<BR>Php-avanzado@pato2.fi.mdp.edu.ar<BR>http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado</BLOCKQUOTE></BODY></HTML>