<?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>ajgraham.com &#187; session</title>
	<atom:link href="http://www.ajgraham.com/tag/session/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ajgraham.com</link>
	<description>web design, development and consultation in Prague</description>
	<lastBuildDate>Tue, 01 Nov 2011 22:16:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Retrieve Facebook page status with no authenticating or permissions issues</title>
		<link>http://www.ajgraham.com/2010/07/get-facebook-page-stream-simple-easy/</link>
		<comments>http://www.ajgraham.com/2010/07/get-facebook-page-stream-simple-easy/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 21:42:11 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[retrieve]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[scraping]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[stream]]></category>

		<guid isPermaLink="false">http://www.ajgraham.com/?p=451</guid>
		<description><![CDATA[If you&#8217;re just looking to read the &#8216;Stream&#8217; or &#8216;Statuses&#8217; of a Facebook fan page (not a normal Profile page) it can be done very easily. Due to all Fan Pages being public (their are 2 settings: published or unpublished), as long as the Fan page is published then you [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re just looking to read the &#8216;Stream&#8217; or &#8216;Statuses&#8217; of a Facebook fan page (<em>not</em> a normal Profile page) it can be done very easily. Due to all Fan Pages being public (their are 2 settings: published or unpublished), as long as the Fan page is published then you can retrieve any data from it, no authentication, no API, no messing around.</p>
<p>Step 1 &#8211; Find the page feed for the Fan Page<br />
The basic URL format of a Facebook fan page feed is:</p>
<pre><code>https://graph.facebook.com/ID of Page/feed</code></pre>
<p>If you can&#8217;t find your unique Page ID <a target="_blank" rel="nofollow" href="http://help.wildfireapp.com/faqs/tutorials/how-to-find-out-your-facebook-fan-page-public-profile-id">read this guide</a>.<br />
<a target="_blank" rel="nofollow" href="https://graph.facebook.com/ID of Page/feed">Test it by opening the link in another browser window</a>. If you get a whole load of data in square and curly brackets (it&#8217;s JSON) that contains posts from your fan page then you&#8217;re set for Step 2.</p>
<p>*Please note that this URL gets every post from your Wall/Stream limited to about the 50 most recent from what I&#8217;ve seen. This includes everything that other people have posted as well in the form of their posts or comments, etc.</p>
<p>Step 2 &#8211; Extract the last status from the feed URL data</p>
<p>Here comes the basic PHP code, you need to put in the Page ID for the
<pre><code>$pageID</code></pre>
<p> variable:</p>
<pre><code>$pageID = "ID of Page"
$url = "https://graph.facebook.com/". $pageID ."/feed";
$json = file_get_contents($url);
$jsonData = json_decode($json);

foreach($jsonData->data as $val) {
	if($val->from->id == $pageID) { //find the first matching post/status by a fan page admin
		$message = $val->message;
		echo $message;
		break; //stop looping on most recent status posted by page admin
	}
}</code></pre>
<h3>Things to consider</h3>
<p>Extracting the data from Facebook directly using a server-side approach should not be used for production as it&#8217;s really inefficient as it adds a noticeable pause to page loading times and will break if Facebook is slow in responding. I provided a basic demo to show how easy it can be done, but you should expand on this by storing the data extracted in a database or file on your server via CRON jobs. Another alternative would be to do it client-side with JavaScript, it depends on the frequency the Fan page data you want is expected to change and what you&#8217;re doing with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajgraham.com/2010/07/get-facebook-page-stream-simple-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

