<?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>Erzwan.com &#187; count</title>
	<atom:link href="http://erzwan.com/category/count/feed" rel="self" type="application/rss+xml" />
	<link>http://erzwan.com</link>
	<description>How-to Tech Guide</description>
	<lastBuildDate>Wed, 18 Aug 2010 12:00:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Display Facebook Fan Count in Text</title>
		<link>http://erzwan.com/how-to-display-facebook-fan-count-in-text.html</link>
		<comments>http://erzwan.com/how-to-display-facebook-fan-count-in-text.html#comments</comments>
		<pubDate>Fri, 18 Jun 2010 13:26:50 +0000</pubDate>
		<dc:creator>hongkiat</dc:creator>
				<category><![CDATA[How-To Guides]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fan]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.hongkiat.com/blog/?p=7695</guid>
		<description><![CDATA[Adding a Facebook Like Button on your website or blog is perhaps one of the [...]]]></description>
			<content:encoded><![CDATA[<p><!--INFOLINKS_OFF--></p>
<p>Adding a Facebook <a href="http://developers.facebook.com/docs/reference/plugins/like">Like Button</a> on your website or blog is perhaps one of the easiest and most effective way to get more fans and earn more <em>likes</em>. If you have hundreds, thousand or perhaps tens of thousand of fans, it might be a good idea to publish a <strong>fan count</strong>. <strong>Fan count displays in numeric text total fans your Facebook page has</strong>, or rather, how many have <em>liked</em> your page.</p>
<p class="center"><img src="http://media02.hongkiat.com/facebook_fancount/preview.jpg" width="500" height="367" alt="facebook fancount" title="How to Display Facebook Fan Count in Text" /></p>
<p>The technique is simple and very similar to <a href="http://www.hongkiat.com/blog/display-google-feed-subscriber-count-in-text/">displaying Google feedcount in text</a>. The only difference is &#8211; we will be using <a href="http://developers.facebook.com/">Facebook&#8217;s API</a>. In this post, we want to show you how it can be done so you can add them into your <strong>WordPress</strong> blog or <strong>PHP</strong> powered website. Load up your favorite code editor, here we go.</p>
<p><span id="more-7695"></span></p>
<h4>Step 1 &#8211; Get API Key, Application Secret &amp; Page ID</h4>
<p>These are the three mandatory information you&#8217;ll need to get things started.</p>
<p><strong><em>API Key and Application Secret</em></strong></p>
<ol>
<li>Sign in to your <a href="http://www.facebook.com">Facebook</a> and click on <a href="http://www.facebook.com/developers?ref=bookmarks">Developer</a>&#8216;s link on the site bar. (If you don&#8217;t have a Developer&#8217;s account, you will have to <a href="http://developers.facebook.com/">sign up</a> for one first)
<p class="center"><img src="http://media02.hongkiat.com/facebook_fancount/facebook-developer-link.jpg" width="176" height="154" alt="facebook developer link" title="How to Display Facebook Fan Count in Text" /></p>
</li>
<li>Click &quot;<strong>Set Up New Application</strong>&quot;. Enter any application name, agree to the Facebook terms and click <strong>&quot;Create Application</strong>&quot;. <strong>Note:</strong> We are not going to create a real application, but we&#8217;ll need to go through these processes to get a <strong>API Key</strong> and <strong>Application Secret</strong>.<br />
  <img src="http://media02.hongkiat.com/facebook_fancount/create-application.jpg" width="500" height="146" alt="create application" title="How to Display Facebook Fan Count in Text" />  </li>
<li>On the next page, you should be able to see your personal <strong>API Key</strong> and <strong>Application Secret</strong>. Copy it down somewhere or leave the browser window open.<br />
  <img src="http://media02.hongkiat.com/facebook_fancount/api-key.jpg" width="500" height="171" alt="api key" title="How to Display Facebook Fan Count in Text" />  </li>
</ol>
<p><strong><em>Page ID</em></strong></p>
<p><strong>Page ID is the ID of your Facebook Fan Page</strong>. If you don&#8217;t have a Facebook Fan page, you&#8217;ll have to first create one. To get the ID of your Fan page, click <em>edit page</em>, and look for your ID (numbers) at the end of the URL &#8211; <code>http://www.facebook.com/pages/edit/?id=<strong>XXXXXXXXX</strong></code></p>
<h4>Step 2 &#8211; Get <code>Facebook.php</code></h4>
<p>You&#8217;ll also need the <strong>Facebook API PHP SDK</strong> file called <code><a href="http://github.com/facebook/php-sdk/blob/master/src/facebook.php">Facebook.php</a></code>. Download it, and place it in the root of your folder. <a href="http://www.hongkiat.com/blog/how-to-display-facebook-fan-count-in-text/Official%20PHP%20SDK"><em>Learn more</em></a><em> about <strong>Facebook PHP SDK</strong>.</em></p>
<p><img src="http://media02.hongkiat.com/facebook_fancount/php-sdk.jpg" width="500" height="216" alt="php sdk" title="How to Display Facebook Fan Count in Text" /></p>
<h4>Step 3 &#8211; Display Fancount</h4>
<p>To show off your fancount, place the following code in your php file,</p>
<pre name="code" class="php">
&lt;?php
require_once('facebook.php');
$facebook = new Facebook(array(
    'appId'  =&gt; 'app_id',
    'secret' =&gt; 'secret_key',
    'cookie' =&gt; true,
));
$result = $facebook-&gt;api(array(
    'method' =&gt; 'fql.query',
    'query' =&gt; 'select fan_count from page where page_id = page_id;'
));
$fb_fans = $result[0]['fan_count'];
?&gt;
</pre>
<p>And then you will want to edit the codes to change the following:</p>
<ul>
<li>Line 4 &#8211; Replace <span class="php"><code>app_id</code></span> with your <strong>Facebook Application ID</strong>.</li>
<li>Line 5 &#8211; Replace <span class="php"><code>secret_key</code></span> with <strong>Secret</strong>.</li>
<li>Line 10 &#8211; Replace the last <code>page_id</code> with your <strong>Facebook Fanpage ID</strong>.</li>
</ul>
<p>Please refer to <em><strong>Step 1</strong></em> on how to get <span class="php"><code>app_id</code></span>, <span class="php"><code>secret_key</code></span> and <code><span class="php">page_id</span></code>.</p>
<p>To display the fancount, insert this following code anywhere in the page:</p>
<pre name="code" class="php">
&lt;?php echo $fb_fans; ?&gt;
</pre>
<p>That&#8217;s all. Style your fancount and make it attractive. See a working example on <a href="http://www.psdeluxe.com/">Psdeluxe</a>&#8216;s top right corner.</p>
<p><!--INFOLINKS_ON--></p>
]]></content:encoded>
			<wfw:commentRss>http://erzwan.com/how-to-display-facebook-fan-count-in-text.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Display Google Feed Subscriber Count in Text</title>
		<link>http://erzwan.com/display-google-feed-subscriber-count-in-text.html</link>
		<comments>http://erzwan.com/display-google-feed-subscriber-count-in-text.html#comments</comments>
		<pubDate>Thu, 22 Jan 2009 10:00:30 +0000</pubDate>
		<dc:creator>hongkiat</dc:creator>
				<category><![CDATA[How-To Guides]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[feedburner]]></category>
		<category><![CDATA[feedproxy]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[subscriber]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.hongkiat.com/blog/?p=3670</guid>
		<description><![CDATA[We previously showed how you can display Feedburner feed count in raw text. However, if [...]]]></description>
			<content:encoded><![CDATA[<p><!--INFOLINKS_OFF--><br />
<img src="http://media02.hongkiat.com/feedburner/subscriber-count-in-text.jpg" alt="subscriber feed count in text" title="Display Google Feed Subscriber Count in Text" /></p>
<p>We previously showed how you can <a href="http://www.hongkiat.com/blog/how-to-display-feedburner-subscriber-count-in-text/">display Feedburner feed count in raw text</a>. However, if you&#8217;ve recently migrated your feed from Feedburner  to Google Feed, you&#8217;ll noticed those codes will no longer work. Here&#8217;s the workarounds, for those who wanted to <strong>display Google Feed subscriber count in text</strong> for better styling.</p>
<p><span id="more-3670"></span></p>
<h3>Previous Code For Feedburner&#8230;</h3>
<p>This code will only work if you intend to display <em><strong>Feedburner</strong></em> feed count in text, but for those who are already on Google Feed, some changes are required.</p>
<pre name="code" class="php">
//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get cool feedburner count
</pre>
<h3>The Solution</h3>
<p>Replace line:2 from:</p>
<pre name="code" class="php">
//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";
</pre>
<p>to the following:</p>
<pre name="code" class="php">
//get cool feedburner count
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=feedburner-id";
</pre>
<h3>The Complete Code</h3>
<p>Here&#8217;s the complete set of code to display Google Feed subscriber count in text. Remember to replace <code>feedburner-id</code> (line:2) with your <em>real</em> feed ID.</p>
<pre name="code" class="php">
//get cool feedburner count
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=feedburner-id";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get cool feedburner count
</pre>
<h3>Troubleshoots</h3>
<p>Here are some of the possibilities if the above code don&#8217;t work for you:</p>
<ul>
<li>Double check if you&#8217;ve correctly replaced <strong><code>http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id</code></strong> with <strong><code>https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=feedburner-id</code></strong></li>
<li>Did you replaced <code>feedburner-id</code> with your actual Feed ID?</li>
<li><code>SimpleXMLElement</code>s requires PHP5. If nothing shows up, chances are your <a href="http://www.hongkiat.com/blog/out/dreamhost" style=""  rel="nofollow" onmouseover="self.status='http://www.hongkiat.com/blog/out/dreamhost';return true;" onmouseout="self.status=''">web host</a> is still on PHP4. You should contact them about the upgrade.</li>
</ul>
<p><!--INFOLINKS_ON--></p>
]]></content:encoded>
			<wfw:commentRss>http://erzwan.com/display-google-feed-subscriber-count-in-text.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
