<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>unijimpe &#187; JSON</title> <atom:link href="http://blog.unijimpe.net/category/json/feed/" rel="self" type="application/rss+xml" /><link>http://blog.unijimpe.net</link> <description>Desarrollo Web, SEO, Adsense</description> <lastBuildDate>Mon, 28 Nov 2011 03:18:21 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Acortar URLs con bit.ly y PHP</title><link>http://blog.unijimpe.net/acortar-urls-con-bit-ly-y-php/</link> <comments>http://blog.unijimpe.net/acortar-urls-con-bit-ly-y-php/#comments</comments> <pubDate>Mon, 20 Jul 2009 05:09:03 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Twitter]]></category> <category><![CDATA[3D]]></category> <category><![CDATA[API]]></category> <category><![CDATA[bit.ly]]></category> <category><![CDATA[Google]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1062</guid> <description><![CDATA[<p><a href="http://bit.ly">Bit.ly</a> es uno de los servicios de acortamiento mas innovadores por que además de acortar el URL brinda estadísticas de accesos y un historial de enlaces acortados. Bit.ly además tiene un API mediante el cual se &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://bit.ly">Bit.ly</a> es uno de los servicios de acortamiento mas innovadores por que además de acortar el URL brinda estadísticas de accesos y un historial de enlaces acortados. Bit.ly además tiene un API mediante el cual se pueden generar dinámicamente los URLs acortados.</p><p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/07/bit.ly.jpg" alt="bit.ly" title="bit.ly" width="123" height="69" /></p><blockquote><p>Para una versión actualizada de este artículo pueden leer: <a href="http://blog.unijimpe.net/acortar-urls-con-php-y-apibitly/">Acortar URLs con PHP y API Bit.ly</a></p></blockquote><p><strong>API del Bit.ly</strong><br /> Este API brinda metodos para acortar y expandir URLs, ver estadisticas y datos del URL. Para mayor información pueden leer <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation">API Libraries and Documentation for bit.ly</a>. Para hacer uso de esta API es necesario tener una cuenta la cual es gratuita.</p><p>Para acortar un URL se puede utilizar el método shorten, para ello se puede acceder a un URL donde <strong>url</strong> es el URL que se desea acortar, <strong>user</strong> es tu nombre de usuario de bit.ly y <strong>key</strong> es nu API Key:</p><p><em>http://api.bit.ly/shorten?version=2.0.1&#038;longUrl=<strong>url</strong>&#038;login=<strong>user</strong>&#038;apiKey=<strong>key</strong></em></p><p>Esto nos devolverá el resultado formateado en JSON, en donde tenemos el estado de la solicitud, los datos del URL sin acortar y acortado.</p><div class="syntax_hilite"><div id="javascript-4"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #3366CC;">"errorCode"</span>: <span style="color: #CC0000;color:#800000;">0</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #3366CC;">"errorMessage"</span>: <span style="color: #3366CC;">""</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #3366CC;">"results"</span>: <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"http://blog.unijimpe.net"</span>: <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"hash"</span>: <span style="color: #3366CC;">"13dmBF"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"shortKeywordUrl"</span>: <span style="color: #3366CC;">""</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"shortUrl"</span>: <span style="color: #3366CC;">"http://bit.ly/5CcBM"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"userHash"</span>: <span style="color: #3366CC;">"5CcBM"</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #3366CC;">"statusCode"</span>: <span style="color: #3366CC;">"OK"</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Entonces podemos utilizar la librería <strong>JSON.php</strong> de la cual hemos comentado en <a href="http://blog.unijimpe.net/json-con-php/">JSON con PHP</a>, entonces crearemos una función llamada <em>getShortenURL</em> que recibirá el URL y lo acortará.</p><div class="syntax_hilite"><div id="php-5"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#000000;">function</span> getShortURL<span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$url</span><span style="color:#006600;">&#41;</span> <span style="color:#006600;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$user</span>&nbsp; = <span style="color:#FF0000;">"username"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$akey</span>&nbsp; = <span style="color:#FF0000;">"apikey"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$path</span>&nbsp; = <span style="color:#FF0000;">"http://api.bit.ly/shorten?version=2.0.1"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$bitly</span> = <span style="color:#0000FF;">$path</span>.<span style="color:#FF0000;">"&amp;longUrl="</span>.<a href="http://www.php.net/urlencode"><span style="color:#000066;">urlencode</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$url</span><span style="color:#006600;">&#41;</span>.<span style="color:#FF0000;">"&amp;login="</span>.<span style="color:#0000FF;">$user</span>.<span style="color:#FF0000;">"&amp;apiKey="</span>.<span style="color:#0000FF;">$akey</span>;&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$data</span> = <a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$bitly</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON<span style="color:#006600;">&#40;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$obj</span> = <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">decode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$obj</span>-&gt;<span style="color:#006600;">errorCode</span> == <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600;">&#41;</span> <span style="color:#006600;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$obj</span>-&gt;<span style="color:#006600;">results</span>-&gt;<span style="color:#0000FF;">$url</span>-&gt;<span style="color:#006600;">shortUrl</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#006600;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#000000;">false</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#006600;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#125;</span></div></li></ol></div></div></div><p></p><p>Finalmente podemos hacer uso de esta función de manera sencilla como podemos ver a continuación:</p><div class="syntax_hilite"><div id="php-6"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$longURL</span> = <span style="color:#FF0000;">"http://blog.unijimpe.net"</span>;</div></li><li style="color:#26536A;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"Long: "</span>.<span style="color:#0000FF;">$longURL</span>.<span style="color:#FF0000;">"&lt;br&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"Short: "</span>.getShortURL<span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$longURL</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Esta función les puede ser útil si desean acortar URLs para luego enviarlas a <em>Twitter</em> o que estén disponibles para dispositivos móviles o enviados por SMS donde hay limitaciones en la cantidad de caracteres utilizados.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/bitly.zip" title="Bit.ly con PHP"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/acortar-urls-con-bit-ly-y-php/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Ranking Delicious con PHP</title><link>http://blog.unijimpe.net/ranking-delicious-con-php/</link> <comments>http://blog.unijimpe.net/ranking-delicious-con-php/#comments</comments> <pubDate>Thu, 16 Jul 2009 04:06:01 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[ActionScript]]></category> <category><![CDATA[API]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[delicious]]></category> <category><![CDATA[feed]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[gratuito]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[online]]></category> <category><![CDATA[reader]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1059</guid> <description><![CDATA[<p><a href="http://delicious.com/">Delicious</a> en un servicio de Bookmarks Online gratuito el cual es muy popular entre los usuarios. Una medida de la popularidad de web es la cantidad de enlaces que han sido guardados en <strong>Delicious</strong>. Veamos &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://delicious.com/">Delicious</a> en un servicio de Bookmarks Online gratuito el cual es muy popular entre los usuarios. Una medida de la popularidad de web es la cantidad de enlaces que han sido guardados en <strong>Delicious</strong>. Veamos una forma de extraer esta información con PHP.</p><p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/07/delicious.jpg" alt="delicious" title="delicious" width="133" height="40" /></p><p><strong>API de Delicious</strong><br /> <em>Delicious</em> brinda una completa API para extraer información de acuerdo a nuestras necesidades, esta información se devuelve en formato XML o JSON la cual esta muy bien documentada en <a href="http://delicious.com/help/json/">Delicious data feeds for news readers and third-party applications</a>.</p><p>Para obtener los datos de una URL, podemos acceder al siguiente URL, donde el URL se ha codificado en formato MD5:</p><div class="syntax_hilite"><div id="code-11"><div class="code"><ol><li style="color:#3A6A8B;"><div style="">http:<span style="color:#FF9933; font-style:italic;">//feeds.delicious.com/v2/json/urlinfo/{url md5} </span></div></li></ol></div></div></div><p></p><p><strong>Obteniendo la información</strong><br /> Entonces primero creamos el URL de la consulta y luego leemos los datos haciendo uso de la función <strong>file_get_contents</strong>. Como esta información es devuelta en formato JSON utilizaremos la librería <em>JSON.php</em> de la cual comentamos en <a href="http://blog.unijimpe.net/json-con-php/">JSON con PHP</a>.</p><div class="syntax_hilite"><div id="php-12"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$url</span> = <a href="http://www.php.net/md5"><span style="color:#000066;">md5</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"http://blog.unijimpe.net/"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$path</span> = <span style="color:#FF0000;">"http://feeds.delicious.com/v2/json/urlinfo/"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$data</span> = <a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$path</span>.<span style="color:#0000FF;">$url</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON<span style="color:#006600;">&#40;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$obj</span> = <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">decode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/print_r"><span style="color:#000066;">print_r</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$obj</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Con lo  cual obtenemos los datos del web consultado como un objeto, en este script hemos impreso los resultados utilizando la función print_r, el cual devuelve lo siguiente:</p><div class="syntax_hilite"><div id="code-13"><div class="code"><ol><li style="color:#3A6A8B;"><div style="">Array <span style="color:#006600;">&#40;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#006600;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600;">&#93;</span> =&gt; stdClass Object <span style="color:#006600;">&#40;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>hash<span style="color:#006600;">&#93;</span> =&gt; 4862ec49f2b5db5467035c90e83c156b</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>title<span style="color:#006600;">&#93;</span> =&gt; unijimpe</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>url<span style="color:#006600;">&#93;</span> =&gt; http:<span style="color:#FF9933; font-style:italic;">//blog.unijimpe.net/</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>total_posts<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">185</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>top_tags<span style="color:#006600;">&#93;</span> =&gt; stdClass Object <span style="color:#006600;">&#40;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>php<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">87</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>css<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">56</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>blog<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">56</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>flash<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">41</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>wordpress<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">40</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>javascript<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">39</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>blogs<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">36</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>actionscript<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">36</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>web<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">30</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#91;</span>tutorial<span style="color:#006600;">&#93;</span> =&gt; <span style="color:#800000;color:#800000;">27</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#41;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600;">&#41;</span></div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#41;</span></div></li></ol></div></div></div><p></p><p><strong>Finalizando</strong><br /> Hemos logrado extraer la información que necesitamos, el siguiente paso es crear una función que se encargue de este proceso la cual llamaremos <em>getDelicious</em> el cual recibe como parámetro del URL que deseamos consultar.</p><div class="syntax_hilite"><div id="php-14"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#000000;">function</span> getDelicious<span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$url</span><span style="color:#006600;">&#41;</span> <span style="color:#006600;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$path</span> = <span style="color:#FF0000;">"http://feeds.delicious.com/v2/json/urlinfo/"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$data</span> = <a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$path</span>.<a href="http://www.php.net/md5"><span style="color:#000066;">md5</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$url</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON<span style="color:#006600;">&#40;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$obj</span> = <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">decode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$obj</span><span style="color:#006600;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600;">&#93;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$item</span> = getDelicious<span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'url'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"Titulo: "</span> . <span style="color:#0000FF;">$item</span>-&gt;<span style="color:#006600;">title</span>. <span style="color:#FF0000;">"&lt;br&gt;"</span>;</div></li><li style="color:#26536A;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"URL: "</span> . <span style="color:#0000FF;">$item</span>-&gt;<span style="color:#006600;">url</span>. <span style="color:#FF0000;">"&lt;br&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"Total: "</span> . <span style="color:#0000FF;">$item</span>-&gt;<span style="color:#006600;">total_posts</span>. <span style="color:#FF0000;">"&lt;br&gt;"</span>;</div></li></ol></div></div></div><p></p><p>Este script recibe el URL a consultar como un parámetro GET, pueden ver el ejemplo funcionando en: <a href="http://samples.unijimpe.net/delicious/?url=http://blog.unijimpe.net/">delicious</a>. Como pueden ver este blog actualmente tiene 185 enlaces en <em>Delicious</em>, pueden cambiar el URL de la consulta para consultar otro dominio.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/delicious.zip" title="Delicious PHP"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/ranking-delicious-con-php/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>JSON con PHP</title><link>http://blog.unijimpe.net/json-con-php/</link> <comments>http://blog.unijimpe.net/json-con-php/#comments</comments> <pubDate>Sun, 14 Jun 2009 17:16:51 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[AJAX]]></category> <category><![CDATA[API]]></category> <category><![CDATA[cache]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[gratuito]]></category> <category><![CDATA[Javascript]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1049</guid> <description><![CDATA[<p><strong>JSON</strong> es un formato de intercambio de información muy practico pues se puede compartir datos como si fueran objetos, originalmente pensado para usarse con <em>Javascript</em> hoy veremos la forma de utilizarlo con PHP.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/json/php.php"></a></p><p><strong>Como utilizar JSON </strong>&#8230;</p>]]></description> <content:encoded><![CDATA[<p><strong>JSON</strong> es un formato de intercambio de información muy practico pues se puede compartir datos como si fueran objetos, originalmente pensado para usarse con <em>Javascript</em> hoy veremos la forma de utilizarlo con PHP.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/json/php.php"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/06/json-php.gif" alt="json-php" title="json-php" width="300" height="287" /></a></p><p><strong>Como utilizar JSON con PHP</strong><br /> Si estamos utilizando PHP4 necesitaremos una clase que encargue de codificar/decodificar los datos en formato JSON. Para ello descargamos la clase <a href="http://mike.teczno.com/JSON/JSON.phps">JSON.php</a>. Luego de ello la incluimos en nuestro archivo y la inicializamos llamando a <em>Services_JSON</em> para luego decodificar los datos con el método decode.</p><div class="syntax_hilite"><div id="php-19"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$obj</span> = <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">decode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span></div></li></ol></div></div></div><p></p><p><strong>Ejemplo de uso</strong><br /> Para desarrollar nuestro ejemplo, obtendremos los datos de <a href="http://code.google.com/apis/ajaxsearch/">Google AJAX Search API</a>, el cual es un servicio que nos utilizar los resultados de búsqueda de Google y devuelve los datos en JSON. Para ello si deseamos obtener los datos de la búsqueda de la palabra <em>'Google'</em> podremos acceder a <a href="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&#038;q=Google">http://ajax.googleapis.com/ajax/services/search/web?v=1.0&#038;q=Google</a>, el cual devolverá los resultados en el siguiente formato:</p><div class="syntax_hilite"><div id="javascript-20"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">"responseData"</span>:</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"results"</span>: <span style="color: #66cc66;">&#91;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"GsearchResultClass"</span>: <span style="color: #3366CC;">"GwebSearch"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"unescapedUrl"</span>: <span style="color: #3366CC;">"http://en.wikipedia.org/wiki/Paris_Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"url"</span>: <span style="color: #3366CC;">"http://en.wikipedia.org/wiki/Paris_Hilton"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"visibleUrl"</span>: <span style="color: #3366CC;">"en.wikipedia.org"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"cacheUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"title"</span>: <span style="color: #3366CC;">"<span style="color: #000099;">\u</span>003cb<span style="color: #000099;">\u</span>003eParis Hilton<span style="color: #000099;">\u</span>003c/b<span style="color: #000099;">\u</span>003e"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"titleNoFormatting"</span>: <span style="color: #3366CC;">"Paris Hilton"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"content"</span>: <span style="color: #3366CC;">"In 2006, she released her debut..."</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"GsearchResultClass"</span>: <span style="color: #3366CC;">"GwebSearch"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"unescapedUrl"</span>: <span style="color: #3366CC;">"http://www.imdb.com/name/nm0385296/"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"url"</span>: <span style="color: #3366CC;">"http://www.imdb.com/name/nm0385296/"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"visibleUrl"</span>: <span style="color: #3366CC;">"www.imdb.com"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"cacheUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"title"</span>: <span style="color: #3366CC;">"<span style="color: #000099;">\u</span>003cb<span style="color: #000099;">\u</span>003eParis Hilton<span style="color: #000099;">\u</span>003c/b<span style="color: #000099;">\u</span>003e"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"titleNoFormatting"</span>: <span style="color: #3366CC;">"Paris Hilton"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"content"</span>: <span style="color: #3366CC;">"Self: Zoolander. Socialite..."</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; ...</div></li><li style="color:#26536A;"><div style="">&nbsp;<span style="color: #66cc66;">&#93;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;<span style="color: #3366CC;">"cursor"</span>: <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #3366CC;">"pages"</span>: <span style="color: #66cc66;">&#91;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"0"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">1</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"4"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">2</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"8"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">3</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"12"</span>,<span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">4</span> <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#93;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #3366CC;">"estimatedResultCount"</span>: <span style="color: #3366CC;">"59600000"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"currentPageIndex"</span>: <span style="color: #CC0000;color:#800000;">0</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #3366CC;">"moreResultsUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp;<span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span>, <span style="color: #CC0000;color:#800000;">200</span>, <span style="color: #003366;">null</span><span style="color: #66cc66;">&#41;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p> Como pueden ver, toda la información esta estructurada como un objeto con lo cual es muy sencillo de acceder a todos los elementos como veremos a continuación.</p><p>Ahora el siguiente paso es obtener los datos de la ruta indicada y decodificarlas para posteriormente mostrarlas en nuestro HTML. Nótese que para hacer uso de este servicio es necesario tener un <em>key</em>, el cual es gratuito y lo pueden obtener en <a href="http://code.google.com/apis/ajaxsearch/signup.html">Sign-up for an AJAX Search API Key</a>.</p><div class="syntax_hilite"><div id="php-21"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color:#FF9933; font-style:italic;">// read data</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$aQue</span> = <span style="color:#FF0000;">"Google"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$aKey</span> = <span style="color:#FF0000;">"TU_API_KEY"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$aUrl</span> = <span style="color:#FF0000;">"http://ajax.googleapis.com/ajax/services/search/web"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#616100;">if</span> <span style="color:#006600;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'q'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color:#0000FF;">$aQue</span> = <a href="http://www.php.net/urlencode"><span style="color:#000066;">urlencode</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'q'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$data</span> = <a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$aUrl</span>.<span style="color:#FF0000;">"?v=1.0&amp;key="</span>.<span style="color:#0000FF;">$aKey</span>.<span style="color:#FF0000;">"&amp;q="</span>.<span style="color:#0000FF;">$aQue</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#FF9933; font-style:italic;">// decode data</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$obj</span> = <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">decode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Hasta este punto tenemos los datos en la variable <strong>$obj</strong>, luego en el cuerpo de nuestro html hacemos un recorrido por cada elemento de los resultados. Como se puede ver en el siguiente código se accede a los elementos como objetos de manera sencilla.</p><div class="syntax_hilite"><div id="php-22"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$results</span> = <span style="color:#0000FF;">$obj</span>-&gt;<span style="color:#006600;">responseData</span>-&gt;<span style="color:#006600;">results</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#616100;">for</span> <span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$i</span>=<span style="color:#CC66CC;color:#800000;">0</span>; <span style="color:#0000FF;">$i</span>&lt;sizeof<span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$results</span><span style="color:#006600;">&#41;</span>; <span style="color:#0000FF;">$i</span>++<span style="color:#006600;">&#41;</span> <span style="color:#006600;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$tmp</span> = <span style="color:#0000FF;">$results</span><span style="color:#006600;">&#91;</span><span style="color:#0000FF;">$i</span><span style="color:#006600;">&#93;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$tmpHTML</span>.= <span style="color:#FF0000;">"&lt;a href=<span style="color:#000099;">\"</span>"</span>.<span style="color:#0000FF;">$tmp</span>-&gt;<span style="color:#006600;">url</span>.<span style="color:#FF0000;">"<span style="color:#000099;">\"</span>&gt;"</span>.<span style="color:#0000FF;">$tmp</span>-&gt;<span style="color:#006600;">title</span>.<span style="color:#FF0000;">"&lt;/a&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$tmpHTML</span>.= <span style="color:#FF0000;">"&lt;br /&gt;"</span>.<span style="color:#0000FF;">$tmp</span>-&gt;<span style="color:#006600;">content</span>.<span style="color:#FF0000;">"&lt;br/&gt;"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$tmpHTML</span>.= <span style="color:#FF0000;">"&lt;i&gt;"</span>.<span style="color:#0000FF;">$tmp</span>-&gt;<span style="color:#006600;">url</span>.<span style="color:#FF0000;">"&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$tmpHTML</span>;</div></li></ol></div></div></div><p></p><p>Podemos mejorar nuestro ejemplo si le agregamos una caja de texto para que ingrese su búsqueda y además de una hoja de estilos para que se vean mejor los resultados, con lo cual obtenemos <a href="http://samples.unijimpe.net/json/php.php">/json/php.php</a>.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/json-php.zip" title="JSON-PHP"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/json-con-php/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Online JSON Parser</title><link>http://blog.unijimpe.net/online-json-parser/</link> <comments>http://blog.unijimpe.net/online-json-parser/#comments</comments> <pubDate>Sun, 08 Mar 2009 00:55:08 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[Servicios Web]]></category> <category><![CDATA[online]]></category> <category><![CDATA[parser]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=987</guid> <description><![CDATA[<p>Para los que desarrollan aplicaciones en donde la información se formatea en JSON que como es un formato de texto plano es muy difícil leer rápidamente el contenido del JSON. Para ello les presentamos una herramienta &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Para los que desarrollan aplicaciones en donde la información se formatea en JSON que como es un formato de texto plano es muy difícil leer rápidamente el contenido del JSON. Para ello les presentamos una herramienta gratuita <a href="http://json.parser.online.fr/">Online JSON Parser</a> que les permitirá formatear automáticamente el contenido JSON para interpretarlo rápidamente.</p><p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/03/jsonparser.gif" alt="jsonparser" title="jsonparser" width="261" height="66" /></p><p>Esta herramienta toma un texto que se ingresa y lo interpreta como un objeto JSON, luego de ello formatea el contenido y lo muestra según el tipo de dato y tabula si es que hay varios niveles de contenido. Otra de las cualidades interesantes es que verifica la sintaxis y resalta la parte que contiene errores de sintaxis.</p><p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/03/jsonparser-screen.gif" alt="jsonparser-screen" title="jsonparser-screen" width="400" height="262" /></p><p>Definitivamente una herramienta sencilla de utilizar pero muy practica y util para los que utilizamos JSON como formato para intercambio de información.</p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/online-json-parser/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Crear JSON con PHP</title><link>http://blog.unijimpe.net/crear-json-con-php/</link> <comments>http://blog.unijimpe.net/crear-json-con-php/#comments</comments> <pubDate>Mon, 24 Nov 2008 03:43:16 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=971</guid> <description><![CDATA[<p><strong>JSON</strong> (<em>JavaScript Object Notation</em>) el formato de intercambio de datos basado en objetos javascript es ampliamente utilizado por la facilidad para codificar y decodificar y por su poco tamaño, en esta ocasión presentamos la &#8230;</p>]]></description> <content:encoded><![CDATA[<p><strong>JSON</strong> (<em>JavaScript Object Notation</em>) el formato de intercambio de datos basado en objetos javascript es ampliamente utilizado por la facilidad para codificar y decodificar y por su poco tamaño, en esta ocasión presentamos la forma de generar estos datos con PHP.</p><p><strong>JSON con PHP4</strong></p><p>En PHP4 JSON no es manejado nativamente por lo cual necesitamos una clase, para ello tenemos <a href="http://mike.teczno.com/JSON/JSON.phps">JSON.php</a> una clase escrita por <em>Michal Migurski</em> el cual tiene dos métodos <em>encode</em> y <em>decode</em> para manipular rápidamente datos en formato JSON.</p><p>Entonces para utilizar esta clase, la incluimos al inicio de nuestro script, y creamos una variable de la clase <em>Services_JSON</em>, luego de ello creamos un array con la información que deseamos codificar y luego utilizamos el método <em>encode</em>.</p><div class="syntax_hilite"><div id="php-27"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$data</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"nombre"</span> =&gt; <span style="color:#FF0000;">"Albert"</span>, <span style="color:#FF0000;">"apellido"</span> =&gt; <span style="color:#FF0000;">"Camus"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">encode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Esto es con un array sencillo, veamos si utilizamos un array multidimensional, por ejemplo un listado de autores.</p><div class="syntax_hilite"><div id="php-28"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600;">&#93;</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"nombre"</span> =&gt; <span style="color:#FF0000;">"Albert"</span>, <span style="color:#FF0000;">"apellido"</span> =&gt; <span style="color:#FF0000;">"Camus"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600;">&#93;</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"nombre"</span> =&gt; <span style="color:#FF0000;">"Ernesto"</span>, <span style="color:#FF0000;">"apellido"</span> =&gt; <span style="color:#FF0000;">"Sabato"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">encode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Pueden ver el resultado de este ejemplo en <a href="http://samples.unijimpe.net/phpjson/data.php">data.php</a>. Ahora si queremos hacer un ejemplo mas complejo, podemos extraer los datos de una tabla de una base de datos MySQL, con lo cual nuestro código sería de la forma:</p><div class="syntax_hilite"><div id="php-29"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#616100;">require_once</span><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"JSON.php"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$json</span> = <span style="color:#000000;">new</span> Services_JSON;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$conexion</span> = <a href="http://www.php.net/mysql_connect"><span style="color:#000066;">mysql_connect</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"localhost"</span>, <span style="color:#FF0000;">"usuario"</span>, <span style="color:#FF0000;">"clave"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><a href="http://www.php.net/mysql_select_db"><span style="color:#000066;">mysql_select_db</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"demo"</span>, <span style="color:#0000FF;">$conexion</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$queEmp</span> = <span style="color:#FF0000;">"SELECT * FROM empresa ORDER BY nombre ASC"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$resEmp</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$queEmp</span>, <span style="color:#0000FF;">$conexion</span><span style="color:#006600;">&#41;</span> or <a href="http://www.php.net/die"><span style="color:#000066;">die</span></a><span style="color:#006600;">&#40;</span><a href="http://www.php.net/mysql_error"><span style="color:#000066;">mysql_error</span></a><span style="color:#006600;">&#40;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$totEmp</span> = <a href="http://www.php.net/mysql_num_rows"><span style="color:#000066;">mysql_num_rows</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$resEmp</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color:#616100;">while</span> <span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$rowEmp</span> = <a href="http://www.php.net/mysql_fetch_assoc"><span style="color:#000066;">mysql_fetch_assoc</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$resEmp</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span> <span style="color:#006600;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color:#0000FF;">$data</span><span style="color:#006600;">&#91;</span><span style="color:#006600;">&#93;</span> = <span style="color:#0000FF;">$rowEmp</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$json</span>-&gt;<span style="color:#006600;">encode</span><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>El resultado de este ejemplo lo pueden ver en <a href="http://samples.unijimpe.net/phpjson/mysql.php">mysql.php</a> y como pueden ver la generación de datos en formato JSON es muy sencillo.</p><p><strong>JSON con PHP5</strong></p><p>A partir de la versión 5.2.0 de PHP fueron añadidas las funciones <em>json_encode</em> y <em>json_decode</em> para manipular nativamente datos en JSON, luego nuestro segundo ejemplo se reduciría al siguiente código:</p><div class="syntax_hilite"><div id="php-30"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600;">&#93;</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"nombre"</span> =&gt; <span style="color:#FF0000;">"Albert"</span>, <span style="color:#FF0000;">"apellido"</span> =&gt; <span style="color:#FF0000;">"Camus"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600;">&#93;</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600;">&#40;</span><span style="color:#FF0000;">"nombre"</span> =&gt; <span style="color:#FF0000;">"Ernesto"</span>, <span style="color:#FF0000;">"apellido"</span> =&gt; <span style="color:#FF0000;">"Sabato"</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> json_encode<span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Obviamente el código es mas pequeño y tiene mejor rendimiento. Ahora esta forma de generar los datos en formato JSON combinado con Javascript, Mootools o con Flash pueden hacer de nuestras web verdaderas aplicaciones interactivas.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/phpjson.zip" title="PHP JSON"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/crear-json-con-php/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>JSON con Mootools</title><link>http://blog.unijimpe.net/json-con-mootools/</link> <comments>http://blog.unijimpe.net/json-con-mootools/#comments</comments> <pubDate>Mon, 21 Jul 2008 00:21:24 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[AJAX]]></category> <category><![CDATA[API]]></category> <category><![CDATA[box.net]]></category> <category><![CDATA[buscador]]></category> <category><![CDATA[cache]]></category> <category><![CDATA[click]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[proxy]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=868</guid> <description><![CDATA[<p><strong>JSON</strong> (<em>JavaScript Object Notation</em>) es un formato basado en Javascript para intercambio de datos. JSON es una alternativa a XML pues brinda sencillez al momento de leer los datos, en Javascript puede ser analizado &#8230;</p>]]></description> <content:encoded><![CDATA[<p><strong>JSON</strong> (<em>JavaScript Object Notation</em>) es un formato basado en Javascript para intercambio de datos. JSON es una alternativa a XML pues brinda sencillez al momento de leer los datos, en Javascript puede ser analizado utilizando eval(), además provee sencillez para manipular los datos. Para mas información acerca de las diferencias con XML además de sus virtudes en: <a href="http://es.wikipedia.org/wiki/JSON">JSON</a>.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/json/search.html"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/07/json-search.gif" alt="" title="json-search" width="400" height="162" class="alignnone size-full wp-image-869" /></a></p><p><strong>Obteniendo los datos</strong><br /> Para nuestro ejemplo vamos a utilizar <a href="http://code.google.com/apis/ajaxsearch/">Google AJAX Search API</a>, el cual es un servicio que nos utilizar los resultados de búsqueda de Google. No utilizaremos la funciones que provee Google si no que lo haremos utilizando JSON, para ello encontramos documentación en <a href="http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje">Flash and other Non-Javascript Environments</a>.</p><p>Si deseamos obtener los resultado de la búsqueda de la palabra Google, lo podemos hacer accediendo al siguiente URL:</p><p><a href="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&#038;q=Google">http://ajax.googleapis.com/ajax/services/search/web?v=1.0&#038;q=Google</a></p><p>Este URL devolverá un objeto conteniendo los resultados de la búsqueda en un array ademas de estadísticas de resultados:</p><div class="syntax_hilite"><div id="javascript-39"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"results"</span>: <span style="color: #66cc66;">&#91;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"GsearchResultClass"</span>: <span style="color: #3366CC;">"GwebSearch"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"unescapedUrl"</span>: <span style="color: #3366CC;">"http://en.wikipedia.org/wiki/Paris_Hilton"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"url"</span>: <span style="color: #3366CC;">"http://en.wikipedia.org/wiki/Paris_Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"visibleUrl"</span>: <span style="color: #3366CC;">"en.wikipedia.org"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"cacheUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"title"</span>: <span style="color: #3366CC;">"<span style="color: #000099;">\u</span>003cb<span style="color: #000099;">\u</span>003eParis Hilton<span style="color: #000099;">\u</span>003c/b<span style="color: #000099;">\u</span>003e"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"titleNoFormatting"</span>: <span style="color: #3366CC;">"Paris Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"content"</span>: <span style="color: #3366CC;">"In 2006, she released her debut..."</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"GsearchResultClass"</span>: <span style="color: #3366CC;">"GwebSearch"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"unescapedUrl"</span>: <span style="color: #3366CC;">"http://www.imdb.com/name/nm0385296/"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"url"</span>: <span style="color: #3366CC;">"http://www.imdb.com/name/nm0385296/"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"visibleUrl"</span>: <span style="color: #3366CC;">"www.imdb.com"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"cacheUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"title"</span>: <span style="color: #3366CC;">"<span style="color: #000099;">\u</span>003cb<span style="color: #000099;">\u</span>003eParis Hilton<span style="color: #000099;">\u</span>003c/b<span style="color: #000099;">\u</span>003e"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"titleNoFormatting"</span>: <span style="color: #3366CC;">"Paris Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"content"</span>: <span style="color: #3366CC;">"Self: Zoolander. Socialite..."</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; ...</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;<span style="color: #66cc66;">&#93;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp;<span style="color: #3366CC;">"cursor"</span>: <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"pages"</span>: <span style="color: #66cc66;">&#91;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"0"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">1</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"4"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">2</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"8"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">3</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"12"</span>,<span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">4</span> <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#93;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"estimatedResultCount"</span>: <span style="color: #3366CC;">"59600000"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #3366CC;">"currentPageIndex"</span>: <span style="color: #CC0000;color:#800000;">0</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"moreResultsUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span></div></li><li style="color:#26536A;"><div style="">&nbsp;<span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span>, <span style="color: #CC0000;color:#800000;">200</span>, <span style="color: #003366;">null</span><span style="color: #66cc66;">&#41;</span></div></li></ol></div></div></div><p></p><p><strong>Creando un Proxy</strong><br /> Normalmente cuando se accede a datos JSON se hacen sobre el mismo dominio, pero como nosotros deseamos acceder a los datos de Google necesitamos crear un <em>proxy</em> para cambiar de dominio los datos recibidos. Esto por que nos browsers no permites acceder a datos de otros dominios. Entonces creamos el archivo <strong>proxy.php</strong>.</p><div class="syntax_hilite"><div id="php-40"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$apiQue</span> = <span style="color:#FF0000;">"Google"</span>; <span style="color:#FF9933; font-style:italic;">// variable a consultar</span></div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$apiKey</span> = <span style="color:#FF0000;">"tu_key_google"</span>; <span style="color:#FF9933; font-style:italic;">// key para acceder al servicio</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$apiUrl</span> = <span style="color:#FF0000;">"http://ajax.googleapis.com/ajax/services/search/web"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#616100;">if</span> <span style="color:#006600;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'query'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color:#0000FF;">$apiQue</span> = <a href="http://www.php.net/urlencode"><span style="color:#000066;">urlencode</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'query'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/readfile"><span style="color:#000066;">readfile</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$apiUrl</span>.<span style="color:#FF0000;">"?v=1.0&amp;key="</span>.<span style="color:#0000FF;">$apiKey</span>.<span style="color:#FF0000;">"&amp;q="</span>.<span style="color:#0000FF;">$apiQue</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p><strong>Cargando los datos con Mootools</strong><br /> La nueva versión de <a href="http://mootools.net">Mootools</a> trae el método <em>Request.JSON</em> que permite cargar y parsear automáticamente datos JSON, para nuestro caso cargaremos los datos del proxy recién creado y lo mostraremos utilizando la función <em>alert</em>. Primero incluimos la librería <em>Mootools</em> en el header de nuestro html y luego obtenemos los datos JSON.</p><div class="syntax_hilite"><div id="html-41"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><div class="syntax_hilite"><div id="javascript-42"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> path = <span style="color: #3366CC;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url: path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> results = obj.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>; i&lt;results.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>i + <span style="color: #3366CC;">" --&gt; "</span> + tmp.<span style="color: #006600;">title</span> + <span style="color: #3366CC;">"<span style="color: #000099;">\n</span>"</span> + tmp.<span style="color: #006600;">url</span><span style="color: #66cc66;">&#41;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Pueden ver el resultado en: <a href="http://samples.unijimpe.net/json/index.html">/json/index.html</a>.</p><p>Como pueden observar, la función onLoad se ejecuta cuando se ha completado la carga de los datos, dentro de esta función podemos acceder a los datos recién cargados como si fueran objetos es decir podemos acceder a todas sus propiedades utilizando el operador punto (<strong>.</strong>).</p><p>Entonces si deseamos mostrar la cantidad total de resultados podríamos hacer mediante <em>obj.estimatedResultCount</em>, entonces para acceder a los resultados de la búsqueda accedemos a <em>obj.responseData.results</em> el cual contiene un array con los resultados de la búsqueda por lo cual utilizamos un FOR para acceder a cada elemento.</p><p>Ahora si deseamos mostrar estos resultados como HTML y no como alerts, lo primero es crear un div en donde escribiremos los resultados y modificar brevemente nuestro script.</p><div class="syntax_hilite"><div id="javascript-43"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> path = <span style="color: #3366CC;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url: path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmpHTML = <span style="color: #3366CC;">""</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> results = obj.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>; i&lt;results.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;a href='"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"'&gt;"</span>+tmp.<span style="color: #006600;">title</span>+<span style="color: #3366CC;">"&lt;/a&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;br /&gt;"</span>+tmp.<span style="color: #006600;">content</span>+<span style="color: #3366CC;">"&lt;br/&gt;"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;i&gt;"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"results"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"html"</span>, tmpHTML<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><div class="syntax_hilite"><div id="html-44"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"results"</span><span style="color: #000000;">&gt;</span></a></span>Loading...<span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li></ol></div></div></div><p></p><p>Pueden ver el resultado en: <a href="http://samples.unijimpe.net/json/json.html">/json/json.html</a>.</p><p>Finalmente, agregamos un campo te texto y un botón para crear un formulario de búsqueda para mostrar la potencia de JSON. Esto lo hacemos con el siguiente código.</p><div class="syntax_hilite"><div id="javascript-45"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> path = <span style="color: #3366CC;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url: path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmpHTML = <span style="color: #3366CC;">""</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> results = obj.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>; i&lt;results.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;a href='"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"'&gt;"</span>+tmp.<span style="color: #006600;">title</span>+<span style="color: #3366CC;">"&lt;/a&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;br /&gt;"</span>+tmp.<span style="color: #006600;">content</span>+<span style="color: #3366CC;">"&lt;br/&gt;"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;i&gt;"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"results"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"html"</span>, tmpHTML<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> sendSearch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"results"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"html"</span>, <span style="color: #3366CC;">"Loading..."</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; path = <span style="color: #3366CC;">"proxy.php?query="</span> + $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"q"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">value</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url:path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"bt"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"click"</span>, sendSearch<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><div class="syntax_hilite"><div id="html-46"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"search"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Buscador JSON</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"q"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"q"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"submit"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"bt"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"bt"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Buscar"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"results"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li></ol></div></div></div><p></p><p>Pueden ver el resultado en: <a href="http://samples.unijimpe.net/json/search.html">/json/search.html</a>.</p><p>Como pueden ver utilizando Mootools para manejar JSON es muy fácil el implementar aplicaciones con acceso remoto a datos o también llamado AJAX solo que no estamos utilizando XML y además tenemos la posibilidad de formatear a nuestro antojo los resultados obtenidos.</p><p style="text-align:center;"><a href="http://www.box.net/shared/6zzb80eo8w"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p><strong>Mas Información</strong></p><ul><li><a href="http://es.wikipedia.org/wiki/JSON">JSON en Wikipedia</a></li><li><a href="http://docs.mootools.net/Request/Request">Mootools - Class: Request</a></li><li><a href="http://docs.mootools.net/Request/Request.JSON">Mootools - Class: Request.JSON</a></li></ul><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/json-con-mootools/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching using disk: basic

Served from: blog.unijimpe.net @ 2012-02-08 10:01:32 -->
