<?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>WordPress Hacks &#187; Twitter</title>
	<atom:link href="http://wordpress-hacks.com/tag/twitter/feed" rel="self" type="application/rss+xml" />
	<link>http://wordpress-hacks.com</link>
	<description>Tips y consejos de WordPress en español</description>
	<lastBuildDate>Wed, 25 Jan 2012 11:59:40 +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>Mostrar cantidad de seguidores -followers- en Twitter en forma de texto</title>
		<link>http://wordpress-hacks.com/mostrar-cantidad-de-followers-en-twitter.php</link>
		<comments>http://wordpress-hacks.com/mostrar-cantidad-de-followers-en-twitter.php#comments</comments>
		<pubDate>Wed, 22 Apr 2009 11:06:01 +0000</pubDate>
		<dc:creator>Neri Aispuro</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[cofigurationphp]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://wordpress-hacks.com/?p=176</guid>
		<description><![CDATA[Mostrar la cantidad de followers, o seguidores, que tenemos en twitter es muy fácil con un poco de código. Debemos agregar el siguiente código al archivo functions.php: Ver texto plano PHP: function string_getInsertedString&#40;$long_string,$short_string,$is_html=false&#41;&#123; &#160; if&#40;$short_string&#38;gt;=strlen&#40;$long_string&#41;&#41;return false; &#160; $insertion_length=strlen&#40;$long_string&#41;-strlen&#40;$short_string&#41;; &#160; for&#40;$i=0;$isaveHTML&#40;&#41;; &#160; $element-&#38;gt;parentNode-&#38;gt;removeChild&#40;$element&#41;; &#160; $html2=$document-&#38;gt;saveHTML&#40;&#41;; &#160; return string_getInsertedString&#40;$html,$html2,true&#41;; &#125; &#160; function [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-186 aligncenter" title="twitter" src="http://wordpress-hacks.com/wp-content/uploads/2009/04/twitter.png" alt="twitter" width="128" height="128" /></p>
<p>Mostrar la cantidad de followers, o seguidores, que tenemos en twitter es muy fácil con un poco de código.<br />
Debemos agregar el siguiente código al archivo functions.php:<span id="more-176"></span></p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showPlainTxt('php-3'); return false;">Ver texto plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> string_getInsertedString<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$long_string</span>,<span style="color:#0000FF;">$short_string</span>,<span style="color:#0000FF;">$is_html</span>=<span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$short_string</span>&amp;gt;=<a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$long_string</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#616100;">return</span> <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$insertion_length</span>=<a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$long_string</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$short_string</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">for</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span>=<span style="color:#CC66CC;color:#800000;">0</span>;<span style="color:#0000FF;">$isaveHTML</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$element</span>-&amp;gt;parentNode-&amp;gt;removeChild<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$element</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$html2</span>=<span style="color:#0000FF;">$document</span>-&amp;gt;saveHTML<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">return</span> string_getInsertedString<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$html</span>,<span style="color:#0000FF;">$html2</span>,<span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> getFollowers<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$username</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$x</span> = <a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"http://twitter.com/"</span>.<span style="color:#0000FF;">$username</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$doc</span> = <span style="color:#000000; font-weight:bold;">new</span> DomDocument;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; @<span style="color:#0000FF;">$doc</span>-&amp;gt;loadHTML<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$x</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$ele</span> = <span style="color:#0000FF;">$doc</span>-&amp;gt;getElementById<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'follower_count'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$innerHTML</span>=<a href="http://www.php.net/preg_replace"><span style="color:#000066;">preg_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/^&amp;lt;[^&amp;gt;]*&amp;gt;(.*)&amp;lt;[^&amp;gt;]*&amp;gt;$/'</span>,<span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\\</span>1"</span>,DOMElement_getOuterHTML<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$doc</span>,<span style="color:#0000FF;">$ele</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$innerHTML</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
No debemos modificar nada de ese código. Ahora tenemos que llamar la función que escribimos en el archivo, por lo que donde querramos mostrar la cantidad de seguidores que tenemos, debemos agregar el código:</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">Ver texto plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> getFollowers<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"usuarioentwitter"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">" texto que querés mostrar luego del número"</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Tenés que modificar el texto "usuarioentwitter" por el nombre de tu usuario, y también modificar el "texto que querés mostrar luego del número" por lo que quieras.</p>
<p>Muchas gracias a <a href="http://www.wprecipes.com/display-the-total-number-of-your-twitter-followers-on-your-wordpress-blog">Wp-Recipes por el Hack</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wordpress-hacks.com/mostrar-cantidad-de-followers-en-twitter.php/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

