<?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>Johan de Bruin &#187; Programacion</title>
	<atom:link href="http://www.johandebruin.com/c/programacion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johandebruin.com</link>
	<description>Programación en php, tutorial de api wordpress y posicionamiento en buscadores seo.</description>
	<lastBuildDate>Sun, 05 Feb 2012 15:18:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Relacionar matematicas de conjuntos con patrones de regex</title>
		<link>http://www.johandebruin.com/relacionar-matematicas-de-conjuntos-con-patrones-de-regex/</link>
		<comments>http://www.johandebruin.com/relacionar-matematicas-de-conjuntos-con-patrones-de-regex/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 22:44:54 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Programacion]]></category>
		<category><![CDATA[Sin categoría]]></category>
		<category><![CDATA[Regex]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=756</guid>
		<description><![CDATA[Math Pattern Pattern meaning no equivalent no character at all matches "" c c matches "c" p1p2 matches p1 then p2 p1&#124;p2 matches p1 or p2 p* matches "" or p repeated p+ matches p repeated, but not "" p? matches p or "" p{n} matches p repeated n times p{n,m} matches p repeated n [...]]]></description>
			<content:encoded><![CDATA[<table border="1">
<tbody>
<tr>
<th>Math</th>
<th>Pattern</th>
<th>Pattern meaning</th>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=Latex%20%5Cemptyset&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Latex \emptyset' title='Latex \emptyset' class='latex' /></td>
<td>no equivalent</td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=Latex%20%5Cepsilon&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Latex \epsilon' title='Latex \epsilon' class='latex' /></td>
<td>no character at all</td>
<td>matches <code>""</code></td>
</tr>
<tr>
<td><code><em>c</em></code></td>
<td><em><code>c</code></em></td>
<td>matches <code>"<em>c</em>"</code></td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L_1%20%5Ccirc%20L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1 \circ L_2' title='L_1 \circ L_2' class='latex' /></td>
<td><em>p1</em><em>p2</em></td>
<td>matches <em>p1</em> then <em>p2</em></td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L_1%20%5Ccup%20L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1 \cup L_2' title='L_1 \cup L_2' class='latex' /></td>
<td><em>p1</em><code>|</code><em>p2</em></td>
<td>matches <em>p1</em> or <em>p2</em></td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L%5E%5Cstar&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L^\star' title='L^\star' class='latex' /></td>
<td><em>p</em><code>*</code></td>
<td>matches <code>""</code> or <em>p</em> repeated</td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L%5E%2B&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L^+' title='L^+' class='latex' /></td>
<td><em>p</em><code>+</code></td>
<td>matches <em>p</em> repeated, but not <code>""</code></td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L%5E%3F&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L^?' title='L^?' class='latex' /></td>
<td><em>p</em><code>?</code></td>
<td>matches <em>p</em> or <code>""</code></td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L%5En&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L^n' title='L^n' class='latex' /></td>
<td><em>p</em><code>{<em>n</em>}</code></td>
<td>matches <em>p</em> repeated <em>n</em> times</td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=L%5E%7B%5Bn%2Cm%5D%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L^{[n,m]}' title='L^{[n,m]}' class='latex' /></td>
<td><em>p</em><code>{<em>n</em>,<em>m</em>}</code></td>
<td>matches <em>p</em> repeated <em>n</em> to <em>m</em> times</td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=Latex%20%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Latex \Sigma' title='Latex \Sigma' class='latex' /></td>
<td><code>.</code></td>
<td>matches any character</td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=Latex%20%5C%7Bc_1%2C%5Cldots%2Cc_n%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Latex \{c_1,\ldots,c_n\}' title='Latex \{c_1,\ldots,c_n\}' class='latex' /></td>
<td><code>[<em>c</em><sub>1</sub>...<em>c<sub>n</sub></em>]</code></td>
<td>matches $c_1$ or $c_2$ or &#8230; or $c_n$</td>
</tr>
<tr>
<td><img src='http://s.wordpress.com/latex.php?latex=Latex%20%5CSigma%20-%20%5C%7Bc_1%2C%5Cldots%2Cc_n%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Latex \Sigma - \{c_1,\ldots,c_n\}' title='Latex \Sigma - \{c_1,\ldots,c_n\}' class='latex' /></td>
<td><code>[^<em>c</em><sub>1</sub>...<em>c<sub>n</sub></em>]</code></td>
<td>matches<br />
any char but $c_1$ or &#8230; or $c_n$</td>
</tr>
<tr>
<td>$(L)$</td>
<td><code>(</code><em>p</em><code>)</code></td>
<td>matches <em>p</em>, remembers submatch</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\</code><em>n</em></td>
<td>matches string from <em>n</em>th submatch</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\b</code></td>
<td>matches a word boundary</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\w</code></td>
<td>matches a word character, e.g., alphanumeric</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\W</code></td>
<td>matches a nonword character, e.g., punctuation</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\s</code></td>
<td>matches a whitespace character, e.g., space, tab, return</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\S</code></td>
<td>matches a non-whitespace character, e.g., alphanumeric, punctuation</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\d</code></td>
<td>matches a digit character, i.e., 0-9</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>\D</code></td>
<td>matches a non-digit character, e.g., alphanumeric, punctuation</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>^</code></td>
<td>matches start of line/string</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>$</code></td>
<td>matches end of line/string</td>
</tr>
<tr>
<td>no equivalent</td>
<td><code>[<em>c</em><sub>1</sub>-<em>c</em><sub>2</sub>]</code></td>
<td>matches $c_1$ through $c_2$</td>
</tr>
</tbody>
</table>
<p>Interesante la tabla que nos trae este artículo sobre el <a href="http://matt.might.net/articles/sculpting-text/" title="Regex">entendimiento de regex</a> (ingles).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/relacionar-matematicas-de-conjuntos-con-patrones-de-regex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crear widget exportable a otras páginas web con el contenido de tu wordpress</title>
		<link>http://www.johandebruin.com/crear-widget-exportable-a-otras-paginas-web-con-el-contenido-de-tu-wordpress/</link>
		<comments>http://www.johandebruin.com/crear-widget-exportable-a-otras-paginas-web-con-el-contenido-de-tu-wordpress/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 11:02:12 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=740</guid>
		<description><![CDATA[Para crear el widget hay 2 pasos fundamentales. Crear un canal RSS con el contenido que deseas exportar Crear el widget, puedes usar uno de las muchas aplicaciones online disponibles o simplemente programarlo Para el primer paso debemos especificar a wordpress que queremos crear un nuevo canal feed RSS, este canal aparecera con la siguiente [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.johandebruin.com/wp-content/uploads/2011/09/rss-icon-transparentpng.jpg" alt="RSS Widget WordPress" title="RSS Widget WordPress" width="150" height="150" class="aligncenter size-full wp-image-741" /><br />
Para crear el widget hay 2 pasos fundamentales.</p>
<ul>
<li>Crear un canal RSS con el contenido que deseas exportar
<li>Crear el widget, puedes usar uno de las muchas aplicaciones online disponibles o simplemente programarlo</li>
</ul>
<p>Para el primer paso debemos especificar a wordpress que queremos crear un nuevo canal feed RSS, este canal aparecera con la siguiente extrucutura URL:</p>
<p>http://www.ejemplo.com/?feed=ejemplo</p>
<p>http://www.ejemplo.com/feed/ejemplo/</p>
<p>Para ello creamos las siguientes funciones:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mostrar_feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;hola mundo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> incluir_feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_feed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publicadas'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mostrar_feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'incluir_feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><span id="more-740"></span><br />
Esto podemos incluirlo como plugin o dentro del archivo functions.php de nuestro theme.</p>
<p>Ahora dentro de la funcion mostrar_feed() indicamos el contenido RSS que queremos crear, aqui un ejemplo del codigo que he usado para <a href="http://www.partidarios.com/?feed=publicadas" title="Publicadas partidarios">http://www.partidarios.com/?feed=publicadas</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mostrar_feed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
	&lt;rss version=&quot;2.0&quot;
	xmlns:content=&quot;http://purl.org/rss/1.0/modules/content/&quot;
	xmlns:wfw=&quot;http://wellformedweb.org/CommentAPI/&quot;
	xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot;
	xmlns:atom=&quot;http://www.w3.org/2005/Atom&quot;
	xmlns:sy=&quot;http://purl.org/rss/1.0/modules/syndication/&quot;
	xmlns:slash=&quot;http://purl.org/rss/1.0/modules/slash/&quot;
	&gt;
&nbsp;
&lt;channel&gt;
	&lt;title&gt;Partidarios&lt;/title&gt;
	&lt;atom:link href=&quot;http://www.partidarios.com/?feed=publicadas&quot; rel=&quot;self&quot; type=&quot;application/rss+xml&quot; /&gt;
	&lt;link&gt;http://www.partidarios.com&lt;/link&gt;
	&lt;description&gt;Feed con las ultimas publicadas de los partidos politicos.&lt;/description&gt;
	&lt;lastBuildDate&gt;Sat, 17 Sep 2011 09:45:25 +0000&lt;/lastBuildDate&gt;
&nbsp;
	&lt;language&gt;es&lt;/language&gt;
	&lt;sy:updatePeriod&gt;hourly&lt;/sy:updatePeriod&gt;
	&lt;sy:updateFrequency&gt;1&lt;/sy:updateFrequency&gt;
	&lt;generator&gt;http://wordpress.org/?v=3.2.1&lt;/generator&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$the_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'cat'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">27</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'meta_key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'publicada'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'meta_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$the_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$the_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$id_partido2</span> <span style="color: #339933;">=</span> get_post_custom_values<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id_partido'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$id_partido</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$id_partido2</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>				
					<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> get_post_custom_values<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'facebook'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id_partido</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$partido</span> <span style="color: #339933;">=</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_partido</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$mensaje</span> <span style="color: #339933;">=</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mensaje</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">245</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$mensaje</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mensaje</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">245</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;item&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;title&gt;<span style="color: #006699; font-weight: bold;">$partido</span>: <span style="color: #006699; font-weight: bold;">$mensaje</span>&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;link&gt;&quot;</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span>get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/link&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;comments&gt;&quot;</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span>get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;#comments&lt;/comments&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;pubDate&gt;&quot;</span><span style="color: #339933;">.</span>get_the_date<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D, d M Y H:i:s O'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/pubDate&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;		&lt;dc:creator&gt;admin&lt;/dc:creator&gt;<span style="color: #000099; font-weight: bold;">\n</span>
						&lt;category&gt;&lt;![CDATA[Mensaje]]&gt;&lt;/category&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;guid isPermaLink=&quot;false&quot;&gt;'</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span>get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/guid&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;description&gt;&lt;![CDATA[]]&gt;&lt;/description&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;content:encoded&gt;&lt;![CDATA[]]&gt;&lt;/content:encoded&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/item&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
	&lt;/channel&gt;
&lt;/rss&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Por ultimo podemos emplear una de las muchas aplicaciones online que genera widgets a partir de archivos RSS. Una de las más sencillas es <a href="http://www.widgeteasy.com" title="Widget Facil" target="_blank">http://www.widgeteasy.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/crear-widget-exportable-a-otras-paginas-web-con-el-contenido-de-tu-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clase de php Http Bot con CURL</title>
		<link>http://www.johandebruin.com/clase-de-php-http-bot-con-curl/</link>
		<comments>http://www.johandebruin.com/clase-de-php-http-bot-con-curl/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 19:35:07 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programacion]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[Clase]]></category>
		<category><![CDATA[clase php]]></category>
		<category><![CDATA[Clases php]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[HTTP bot]]></category>
		<category><![CDATA[http bot php]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=696</guid>
		<description><![CDATA[Esta clase de php sirve para enviar solicitudes a un servidor a través de un protocolo HTTP usando la tecnologia CURL, ya sea para obtener el codigo HTML de la página usando el metodo GET, o postear algo a través del método POST. Recordad que podeis obtener la cookie usando programas de SNIFER tales como [...]]]></description>
			<content:encoded><![CDATA[<p>Esta clase de php sirve para enviar solicitudes a un servidor a través de un protocolo HTTP usando la tecnologia <a href="http://es.wikipedia.org/wiki/CURL">CURL</a>, ya sea para obtener el codigo HTML de la página usando el metodo GET, o postear algo a través del método POST.</p>
<p>Recordad que podeis obtener la cookie usando programas de SNIFER tales como el plugin para firefox <a href="https://addons.mozilla.org/es-es/firefox/addon/tamper-data/">tamper data</a>, gracias a esta libreria se puede configurar el alta automatica de nuevas entradas de post en clasificados, lista de enlaces, etc&#8230;</p>
<p>La forma en la que se usa esta clase es la siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;curlbot.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bot</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> curlbot<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bot</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;b.txt&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$mensaje</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;_method=POST&amp;data%5BUser%5D%5Bname%5D=usuario&amp;data%5BUser%5D%5Bpassword%5D=contrasena&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$bot</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.mister-wong.es/users/login/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$mensaje</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$bot</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.mister-wong.es/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;fin&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><span id="more-696"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000000; font-weight: bold;">class</span> curlbot
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$encabezado</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$galleta</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Cambiar a false en caso de que no se quiera redireccionar</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$redireccionar</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Definimos como deben establecerse los atributos</span>
	<span style="color: #000000; font-weight: bold;">function</span> __set<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;galleta&quot;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;encabezado&quot;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">encabezado</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redireccionar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Envia una solicitud get y devuelve la pagina obtenida</span>
		<span style="color: #666666; font-style: italic;">///Param{$url}: url de la pagina que queramos obtener</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">encabezado</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">encabezado</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_COOKIEJAR<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_FOLLOWLOCATION<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redireccionar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Enviamos la petición</span>
		<span style="color: #000088;">$respuesta</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$respuesta</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Envia una solicitud post y devuelve la pagina obtenida</span>
		<span style="color: #666666; font-style: italic;">//Param{$url}: dirección de la pagina que solicitamos el post</span>
		<span style="color: #666666; font-style: italic;">//Param{$campos}: mensaje del post que queramos enviar, ejemplo:</span>
			<span style="color: #666666; font-style: italic;">//&quot;user=usuario&amp;pass=contraseña&quot;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span><span style="color: #000088;">$campos</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">encabezado</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">encabezado</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_COOKIEJAR<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">galleta</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$campos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_FOLLOWLOCATION<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redireccionar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Enviamos la petición</span>
		<span style="color: #000088;">$respuesta</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$respuesta</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?</span>php<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/clase-de-php-http-bot-con-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Etiquetas semanticas en HTML5</title>
		<link>http://www.johandebruin.com/etiquetas-semanticas-en-html5/</link>
		<comments>http://www.johandebruin.com/etiquetas-semanticas-en-html5/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 08:19:39 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Programacion]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=686</guid>
		<description><![CDATA[Gracias al uso de HTML5 ahora podremos de forma nativa incorporar una serie de etiqutas, que aunque a la hora de visualizar la página no se reflejan, ayudaran al buscador a que comprenda un poco más la semántica de la página. Mark Su homologo podria ser &#60;strong&#62; con la diferencia que no boldeará el texto. [...]]]></description>
			<content:encoded><![CDATA[<p>Gracias al uso de HTML5 ahora podremos de forma nativa incorporar una serie de etiqutas, que aunque a la hora de visualizar la página no se reflejan, ayudaran al buscador a que comprenda un poco más la semántica de la página.</p>
<h3>Mark</h3>
<p>Su homologo podria ser &lt;strong&gt; con la diferencia que no boldeará el texto. la usaremos para destacar algo importante al buscador dentro de texto.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;M&gt;Texto a resaltar&lt;/M&gt;</pre></div></div>

<h3>Time</h3>
<p>Util para establecer un tiempo, se puede usar para marcar fechas de cuando escribimos el contenido, su uso:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;TIME&gt;April, 23, 2010&lt;/TIME&gt;</pre></div></div>

<h3>Meter</h3>
<p>Co esto podremos señalar que cierto texto es un valor cuantificable. ¿os imaginais si alguien busca una moto a 400€ puedan llegar a vuestra página donde vendeis una a 390€?, esto ahora es posible gracias a esta etiqueta.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;METER value=&quot;120&quot; min=&quot;0&quot; max=&quot;200&quot; low=&quot;60&quot; high=&quot;200&quot; optimum=&quot;200&quot;&gt;120 años&lt;/METER&gt;</pre></div></div>

<h3>Progress</h3>
<p>Para representar progresos de cualquier evento.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;PROGRESS value=&quot;100&quot; max=&quot;1000&quot;&gt;10%&lt;/PROGRESS&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/etiquetas-semanticas-en-html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>API Facebook Graph con PHP, funciones basicas</title>
		<link>http://www.johandebruin.com/api-facebook-graph-con-php-funciones-basicas/</link>
		<comments>http://www.johandebruin.com/api-facebook-graph-con-php-funciones-basicas/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 15:50:28 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programacion]]></category>
		<category><![CDATA[api facebook]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[facebook open graph]]></category>
		<category><![CDATA[php facebook]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=642</guid>
		<description><![CDATA[Bueno, tras un mesecillo sin publicar nada quiero consolidar el conocimiento con el que últimamente he trabajado, por lo que relataré en este artículo como usar la nueva API de Facebook Graph para poder programar aplicaciones empleandola. Para descargar la última versión de la libreria de PHP de facebook podeis visitar el sdk de php [...]]]></description>
			<content:encoded><![CDATA[<p>Bueno, tras un mesecillo sin publicar nada quiero consolidar el conocimiento con el que últimamente he trabajado, por lo que relataré en este artículo como usar la nueva API de Facebook Graph para poder programar aplicaciones empleandola.</p>
<p>Para descargar la última versión de la libreria de PHP de facebook podeis visitar el <a title="facebook sdk api php" href="http://github.com/facebook/php-sdk/">sdk de php de facebook</a>.</p>
<p>La nueva tecnologia de facebook permite tanto consultar como desarrollar distintas aplicaciones usando unicamente la funcion $facebook->api(parametros). Discutiremos una serie de cosas de entre ellas será:</p>
<ol>
<li>Crear el archivo de configuración de API facebook</li>
<li>Autentificar al usuario solicitandole los permisos necesarios</li>
<li>Solicitar información a facebook usando FQL</li>
<li>Actualizar el estado de facebook o publicar en el muro de uno de sus amigos</li>
</ol>
<p><span id="more-642"></span><br />
Archivo config.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APP_ID'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id aplicacion'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'API_KEY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Key API'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SECRET'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Key Secreta de la aplicacion'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">'appId'</span>  <span style="color: #339933;">=&gt;</span> API_KEY<span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> SECRET<span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ahora que el objeto $facebook se ha creado, comprobaremos si se ha iniciado la sesión, en caso contrario la redirigiremos a una página donde el usuario concederá los permisos necesarios para obtener información de su perfil, publicar en su estado, enviarle e-mails, etc&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sesion</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$sesion</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$loginUrl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span>
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'canvas'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'fbconnect'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'req_perms'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'publish_stream,read_stream,user_photo_video_tags,user_photos,friends_photos'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'next'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://urlsiconsienten.com'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'cancel_url'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://facebook.com/'</span>
&nbsp;
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;fb:redirect url=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$loginUrl</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A menudo necesitaremos el ID de la persona autentificada, esto se consigue de la siguiente forma:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fbusuario</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Si quisieramos solicitar información sobre un usuario concreto, podemos emplear el lenguaje <a href="http://developers.facebook.com/docs/reference/fql/">FQL </a>(de facebook query language), junto con el graph api de facebook de php.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fql</span>    <span style="color: #339933;">=</span>   <span style="color: #0000ff;">&quot;select name, hometown_location, sex, pic_square from user where uid=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$fbusuario</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$param</span>  <span style="color: #339933;">=</span>   <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'method'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'fql.query'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'query'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$fql</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'callback'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$fqlResult</span>   <span style="color: #339933;">=</span>   <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Esto nos devolverá una matriz con los datos correlacionados, otras acciones que podemos realizar con la api de facebook es publicar un estado en nuestro propio muro o en el muro de otra persona/página en la que estemos autorizados a hacerlo (gracias a los permisos).</p>
<p>Para ello podemos emplear el siguiente código:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Este se publicara en el muro del usuario autentificado</span>
<span style="color: #000088;">$statusUpdate</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me/feed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'message'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'H.O.L.A M.U.N.D.O'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cb'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Este se publicará en el id del usuario</span>
<span style="color: #000088;">$statusUpdate</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/1304862638/feed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'message'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'H.O.L.A M.U.N.D.O'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cb'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>También se puede emplear el metodo anterior (llamado legacy), para solicitar otro tipo de información, como las peliculas del perfil de usuario, más información en el <a href=http://developers.facebook.com/docs/api">graph API de facebook</a> o también información de cada <a href="http://developers.facebook.com/docs/reference/api/">elemento de la api de facebook</a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$movies</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me/movies'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/api-facebook-graph-con-php-funciones-basicas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Estructura HTML5</title>
		<link>http://www.johandebruin.com/estructura-html5/</link>
		<comments>http://www.johandebruin.com/estructura-html5/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 19:21:52 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Programacion]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Estructura pagina web]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[web semantica]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=631</guid>
		<description><![CDATA[Desde que apareció html5 las etiquetas son semánticas, ahora se definen mejor cada uno de los campos, con lo cual podemos indicar cual es el menú de navegación, cual es el encabezado de la página, y donde esta el contenido relevante. En seogadget.co.uk crearon dos esquemas en el que podemos apreciar los cambios de paradigma. [...]]]></description>
			<content:encoded><![CDATA[<p>Desde que apareció html5 las etiquetas son semánticas, ahora se definen mejor cada uno de los campos, con lo cual podemos indicar cual es el menú de navegación, cual es el encabezado de la página, y donde esta el contenido relevante. En seogadget.co.uk crearon dos esquemas en el que podemos apreciar los cambios de paradigma.</p>
<p><a href="http://www.johandebruin.com/wp-content/uploads/2010/11/paradigma-html5.jpg"><img class="aligncenter size-full wp-image-632" title="paradigma html5" src="http://www.johandebruin.com/wp-content/uploads/2010/11/paradigma-html5.jpg" alt="paradigma html5" width="500" height="155" /></a><br />
<span id="more-631"></span><br />
En html4 definiamos las estructuras a través de etiquetas &lt;div&gt;, los buscadores no distinguen la diferencia enttre uno y otro, por lo que tratan a todo el site con la misma relevancia.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!-- Codigo de head --&gt;
&lt;h1&gt;Titulo pagina&lt;/h1&gt;
&lt;h3&gt;Resumen relevante&lt;/h3&gt;
&lt;!-- Menu de navegación --&gt;</pre></div></div>

<p>Llegados a este punto hemos definido un encabezado, aquí deberemos aprovechar para<br />
mencionar el título de la página y además un resumen donde colar las 2 o 3 keywords más<br />
relevantes. Ahora para el contenido de la página podemos usar la siguiente estructura base:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>article<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>header<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span>Titulo del contenido<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>header<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>section<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Bla bla bla<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>section<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>section<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Bla bla bla<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>section<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>footer<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dublincore issued&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">-</span><span style="color:#800080;">09</span><span style="color: #339933;">-</span><span style="color:#800080;">09</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>footer<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>article<span style="color: #339933;">&gt;</span></pre></div></div>

<p>En el artículo podemos volver a definir las etiquetas header o footer para indicar la relevancia dentro del articulo. Además he incluido un pequeño microformato de dublincore para indicar en el footer la fecha del artículo (gracias a class=&#8221;dublincore issued&#8221; los buscadores pueden reconocerla). Ahora solo nos queda definir la última parte de una estructura HTML, el menú de navegación y el footer.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;aside&gt;
&lt;!-- una lista del menu de la página --&gt;
&lt;/aside&gt;
&lt;footer&gt;
&lt;!-- créditos --&gt;
&lt;/footer&gt;</pre></div></div>

<p>Con esto ya podriamos cerra la página html con body y html. Es importante recalcar la importancia de mantener el contenido más relevante y que queremos posicionar dentro de las etiquetas<br />
<header> y los detalles técnicos o informativos en las etiquetas de footer, así podremos controlar la relevancia del contenido de forma arbitraria.</p>
<p>Ahora que hemos sustituido el antiguo div por etiquetas más específicas, debemos maquetar sobre ellas, la forma de enlazar a un archivo .css ha cambiado ligeramente, también la forma de especificar estilos (antes era a través de clases y títulos para diversificar entre los div, ahora maquetaremos sobre los elementos html directamente).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body<span style="color: #00AA00;">&gt;</span>header <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#093</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&gt;</span>header h1 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/estructura-html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2 dominios, 2 idiomas, htaccess, wordpress, alias y 1 servidor</title>
		<link>http://www.johandebruin.com/2-dominios-2-idiomas-htaccess-wordpress-alias-y-1-servidor/</link>
		<comments>http://www.johandebruin.com/2-dominios-2-idiomas-htaccess-wordpress-alias-y-1-servidor/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 11:15:44 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programacion]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=615</guid>
		<description><![CDATA[Hoy voy a hablaros de una de las tecnicas mas enrevesadas para conseguir que tengamos 2 idiomas en un mismo servidor pero usando 2 dominios distintos (y asi reforzar el posicionamiento seo por dominios del pais). La forma en la que os lo muestro es usando wordpress, pero por supuesto se podria adaptar para otros [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy voy a hablaros de una de las tecnicas mas enrevesadas para conseguir que tengamos 2 idiomas en un mismo servidor pero usando 2 dominios distintos (y asi reforzar el posicionamiento seo por dominios del pais).</p>
<p>La forma en la que os lo muestro es usando wordpress, pero por supuesto se podria adaptar para otros cms o vuestros propios sistemas. Primero deciros que usaremos el plugin de traducción de idiomas estilo <a href="http://wordpress.org/extend/plugins/zdmultilang/">zdMultilang</a> que nos permitira crear subdirectorios estilo dominioprincipal.es/en/ para las traducciones.</p>
<p>Una vez hecho esto, debeis añadir un <a href="http://www.seocharlie.com/blog/los-alias-de-dominio-y-el-posicionamiento-seo">alias </a>al dominio principal para que al entrar desde el segundo dominio conecte con las dns del servidor principal.</p>
<p>Ahora comenzamos a tocar las lineas de codigo, primero abriremos el htaccess y añadiremos las siguientes instrucciones para que el dominio secundario haga un proxy al dominio principal y obtenga la url actual pero añadiendo /en/ al host. En este ejemplo el dominio principal es un .es y el dominio secundario (en ingles o internacional) es el .com:</p>

<div class="wp_syntax"><div class="code"><pre class="robots" style="font-family:monospace;">RewriteEngine on
RewriteCond %<span style="color: #66cc66;">&#123;</span>HTTP_HOST<span style="color: #66cc66;">&#125;</span> ^<span style="color: #66cc66;">&#40;</span>www\.<span style="color: #66cc66;">&#41;</span>?dominiosecundario\.com <span style="color: #66cc66;">&#91;</span>NC<span style="color: #66cc66;">&#93;</span>
RewriteRule ^<span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>$ http<span style="color: #66cc66;">:</span>//www.dominioprincipal.es/en/$1 <span style="color: #66cc66;">&#91;</span>P<span style="color: #66cc66;">&#93;</span>
&nbsp;
RewriteRule ^/?<span style="color: #66cc66;">&#40;</span>en<span style="color: #66cc66;">&#41;</span>/wp-<span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>$ /wp-$2 <span style="color: #66cc66;">&#91;</span>L<span style="color: #66cc66;">&#93;</span></pre></div></div>

<p><span id="more-615"></span><br />
Además, añadirmos la instrucción RewriteRule ^/?(en)/wp-(.*)$ /wp-$2 [L] para que todos las peticiones que comiencen con wp- ignoren el /en/. Esto se hace para que en la versión inglesa pueda obtener el contenido de imagenes, o scripts de forma correcta..</p>
<p>Ahora incluiremos algunas líneas de código de wordpress, que haran que detecten si se está en el dominio secundario y cambie las url de las imagenes y los scripts a este dominio con tal de evitar incompatibilidades de rutas, etc.. Estas lineas se pueden incluir en el archivo functions.php del theme o en forma de plugin, esto se pone a vuestra discreción&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bloginfo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mybloginfo'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bloginfo_url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mybloginfo'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mybloginfo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$show</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/en/'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #990000;">ereg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dominioprincipal.es'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'dominiosecundario.com'</span><span style="color: #339933;">,</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Bien, ya tenemos hecho la base necesaria para poder incluir un segundo idioma en el servidor con 2 dominios distintos, podemos usar la instrucción if (strpos($_SERVER['REQUEST_URI'],&#8217;/en/&#8217;) > -1) para detectar si estamos en la versión inglesa de la traducción y cambiar valores del contenido, como menus, o rutas&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/2-dominios-2-idiomas-htaccess-wordpress-alias-y-1-servidor/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Configurar el loop de wordpress</title>
		<link>http://www.johandebruin.com/configurar-el-loop-de-wordpress/</link>
		<comments>http://www.johandebruin.com/configurar-el-loop-de-wordpress/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 11:26:26 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[API wordpress]]></category>
		<category><![CDATA[Custom loop]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=609</guid>
		<description><![CDATA[Hoy os traigo otro artículo para incorporarlo en la api de wordpress, el loop de wordpress es invocado cada vez que solicitamos articulos o páginas, en el index por ejemplo sale por defecto la solicitud de los últimos artículos publicados, en el archivo los articulos de cierto mes o cierta categoria, etc&#8230; La api de [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy os traigo otro artículo para incorporarlo en la <a href="http://www.johandebruin.com/tutorial-api-wordpress/">api de wordpress</a>, el <strong>loop de wordpress </strong>es invocado cada vez que solicitamos articulos o páginas, en el index por ejemplo sale por defecto la solicitud de los últimos artículos publicados, en el archivo los articulos de cierto mes o cierta categoria, etc&#8230;</p>
<p>La <strong>api de wordpress nos permite una configuración bastante intensa </strong>de la forma de solicitar y mostrar contenido en los loops de wordpress, lo primero de todo es establecer los posts que queramos mostrar en el loop, se puede hacer usando la función <a href="http://codex.wordpress.org/Function_Reference/query_posts">query_posts()</a>;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat=4,5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Todos los que esten en la categoria 4 y 5</span>
query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tag=mitag'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Los que tengan cierto tag...</span>
query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'meta_key=nombrekey&amp;amp;meta_value=valorkey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Tenga un campo personalizado con dichos valores</span>
&nbsp;
 <span style="color: #000088;">$categoria</span><span style="color: #339933;">=</span><span style="color: #000088;">$cat</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// asignamos la actual categoria</span>
 <span style="color: #000088;">$query</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'cat='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$categoria</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;amp;orderby=date&amp;amp;order=ASC'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ordenacion ascendente por fecha</span>
 query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><span id="more-609"></span><br />
Como veis, tenemos mucho con que jugar a la hora de configurar el contenido del loop de wordpress, una vez hecho podemos crear el loop, tiene la siguiente estructura:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//...</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">//...</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
wp_reset_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Importante reiniciar loop para que wordpress funcione como habitualmente</span></pre></div></div>

<p>Una vez dentro del loop podemos llamar a muchos valores de los posts, como por ejemplo el contenido, los tags, fecha, titulos, extracto, campos personalizados, la categoria&#8230; Aquí un ejemplo de como seria el código completo</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">query_posts('cat='.get_cat_ID('miCategoria')); //Establecemos el query con los posts de &quot;miCategoria&quot;
if (have_posts()) : while (have_posts()) : the_post();
     &lt;p&gt;&lt;h1&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;&lt;/p&gt;
     &lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$postMeta</span> <span style="color: #339933;">=</span> get_post_custom_values<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'metaKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$postMeta</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #006699; font-weight: bold;">$key</span>  =&gt; <span style="color: #006699; font-weight: bold;">$value</span> ('metaKey')&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
endwhile; else:
    echo &quot;No se encontraron articulos relacionados, puede que le interese alguna de las siguientes categorias&quot;
&lt;ul&gt;
   <span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_categories<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;
endif;
wp_reset_query();</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/configurar-el-loop-de-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crear Plantillas de themes para post en WordPress</title>
		<link>http://www.johandebruin.com/crear-plantillas-de-themes-para-post-en-wordpress/</link>
		<comments>http://www.johandebruin.com/crear-plantillas-de-themes-para-post-en-wordpress/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 20:42:28 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Custom Values]]></category>
		<category><![CDATA[Plantilla]]></category>
		<category><![CDATA[Post meta]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[Wordpress API]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=599</guid>
		<description><![CDATA[Podemos crear una plantilla para publicar post especificos en wordpress de la misfa forma que ocurre con las páginas gracias a la combinación del uso de la API de wordpress y del plugin Custom Post Template. Lo que queremos conseguir es mostrar posts de distintas maneras en función a que plantilla seleccionamos en el menu [...]]]></description>
			<content:encoded><![CDATA[<p>Podemos crear una plantilla para publicar post especificos en wordpress de la misfa forma que ocurre con las páginas gracias a la combinación del uso de la API de wordpress y del plugin <a title="Plantilla Post WordPress" href="http://wordpress.org/extend/plugins/custom-post-template/">Custom Post Template</a>. Lo que queremos conseguir es mostrar posts de distintas maneras en función a que plantilla seleccionamos en el menu de post:</p>
<p><a href="http://www.johandebruin.com/wp-content/uploads/2010/06/post-template.jpg"><img src="http://www.johandebruin.com/wp-content/uploads/2010/06/post-template.jpg" alt="" title="post template" width="296" height="365" class="aligncenter size-full wp-image-600" /></a></p>
<p>Gracias a eso, y a un formato de recognición de templates de post, con que añadamos el siguiente comentario en el .php del theme de wordpress podremos definir un formato especifico para ese tipo de post (como añadir metas especificos, imagenes, colores, opciones etc&#8230; especifico), explotando más las posibilidades de wordpress.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Template Name Posts: nombrePlantilla
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><span id="more-599"></span><br />
Aqui un ejemplo de como podriamos adaptar esta plantilla usando comandos de la API de wordpress (lo tipico, llamada al header, titulos, contenido, campos personalizados.. ).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Template Name Posts: nombrePlantilla
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
   &lt;h1&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;
   <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;p class=&quot;serif&quot;&gt;Leer el resto del post;&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   $postMeta = get_post_custom_values('metaKey');
   foreach ( $postMeta as $key =&gt; $value ) {
      echo &quot;$key  =&gt; $value ('metaKey')&lt;br /&gt;&quot;; 
   }
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/crear-plantillas-de-themes-para-post-en-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mostrar elementos ocultados con javascript</title>
		<link>http://www.johandebruin.com/mostrar-elementos-ocultados-con-javascript/</link>
		<comments>http://www.johandebruin.com/mostrar-elementos-ocultados-con-javascript/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 17:55:26 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mostrar contenido]]></category>
		<category><![CDATA[ocultar contenido]]></category>
		<category><![CDATA[snnipet]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=593</guid>
		<description><![CDATA[Aquí una rápida pieza de código que permitira ocultar contenido para luego mostrarlo si así lo quiere el usuario. Empleamos javascript junto al reconocimiento DOM de elementos html para definir el contenido de un div. &#60;head&#62; &#60;script type=&#34;text/javascript&#34;&#62; function mostrar() { document.getElementById(&#34;contenedor&#34;).innerHTML = 'hola mundo'; } &#60;/script&#62; &#60;/head&#62; &#60;body&#62; &#60;a href=&#34;javascript://&#34; onclick=&#34;mostrar()&#34;&#62;Mostrar contenido del contenedor&#60;/a&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Aquí una rápida pieza de código que permitira ocultar contenido para luego mostrarlo si así lo quiere el usuario. Empleamos javascript junto al reconocimiento DOM de elementos html para definir el contenido de un div.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function mostrar()
{
	document.getElementById(&quot;contenedor&quot;).innerHTML = 'hola mundo';
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;a href=&quot;javascript://&quot; onclick=&quot;mostrar()&quot;&gt;Mostrar contenido del contenedor&lt;/a&gt;
&lt;div id=&quot;contenedor&gt;
&lt;!-- Este contenedo ahora mismo esta vacio --&gt;
&lt;/div&gt;</pre></div></div>

<p><span id="more-593"></span><br />
Y así de facil, únicamente tenemos que hacer referencia con el atributo de onclick a la función que insertara contenido al elemento que queramos mostrar, también sirve para cambiar de imagen, únicamente deberiamos usar el atributo de javascript document.getElementById(&#8220;contenedor&#8221;).src al hacer click a la imagen&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/mostrar-elementos-ocultados-con-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

