<?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>web2.0goodies.com &#187; Profile Tabs</title>
	<atom:link href="http://web2.0goodies.com/blog/category/facebook/profile-tabs/feed/" rel="self" type="application/rss+xml" />
	<link>http://web2.0goodies.com/blog</link>
	<description>Tips, Tricks, and How To's for Web 2.0</description>
	<lastBuildDate>Tue, 03 Jan 2012 05:34:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Facebook Profile Tab Application (FBML)</title>
		<link>http://web2.0goodies.com/blog/facebook/facebook-profile-tab-application-fbml/</link>
		<comments>http://web2.0goodies.com/blog/facebook/facebook-profile-tab-application-fbml/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 03:17:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Profile Tabs]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/?p=102</guid>
		<description><![CDATA[To Start with, setup your application with these instructions: (Insert link here). Receiving Facebook Posts You FBML application will receive information from Facebook in the form of a signed post. To determine if a post from facebook is authentic, there is an algorithm described here. I have written a class I use that looks like [...]]]></description>
			<content:encoded><![CDATA[<p>To Start with, setup your application with these instructions:  (Insert link here).</p>
<h3>Receiving Facebook Posts</h3>
<p>You FBML application will receive information from Facebook in the form of a signed post.  <a href=" http://wiki.developers.facebook.com/index.php/Verifying_The_Signature">To determine if a post from facebook is authentic, there is an algorithm described here.</a></p>
<p>I have written a class I use that looks like this:  </p>
<pre name="code" class="php">
require_once('config.php');

class Joey_Facebook{
	public static function getFacebookParams(){
		if(!isset($_POST['fb_sig'])) throw new Joey_Facebook_Exception("No Facebook Signatore Parameter");

	    $parameters = $_POST;    

	    if(self::authenticatePayloadFromFacebook($parameters, FACEBOOK_APPLICATION_SECRET)){
	    	return $parameters;
	    }
	    else{
	    	throw new Joey_Facebook_Exception("Parameters Do Not Authenticate!");
	    }
	}

	private static function authenticatePayloadFromFacebook($parameters, $application_secret){
		ksort($parameters);
	    $payload = '';

		foreach ($parameters as $key => $value) {
	        if ($key != 'fb_sig') {
	            $payload .= substr($key, 7) . '=' . $value;
	        }
	    }

	    if (md5($payload . $application_secret) == $parameters['fb_sig']) {
	    	return true;
	    }
	    else{
	    	return false;
	    }
	}
}

class Joey_Facebook_Exception extends Exception{
	public $msg;
	public function __construct($msg){
		$this->msg = $msg;
	}
}
</pre>
<p>Once you have authenticated the request,  you can now use the data in it.  The important data (to me) is&#8230;</p>
<p>When a user has granted your appliation basic permissions, the $_POST['fb_sig_user'] is the facebook users id.  Your application can use this to store and retrieve database records, display customized content, etc&#8230;</p>
<p>If your application is viewed via a profile tab, the profile owner&#8217;s fbid is in $_POST['fb_sig_profile_id'].</p>
<p>With these two basic pieces of information you can essentialy embed basic web applications into Facebook.  You can gather much more information from the post, and also use Facebook&#8217;s API (btw&#8230;  It does need to be de-mistified&#8230;) to gather more information about the user and add more social features to your application.</p>
<h3>Getting a user to &#8220;Add Application&#8221;</h3>
<p><a href="http://wiki.developers.facebook.com/index.php/Authorization_and_Authentication_for_Canvas_Page_Applications_on_Facebook">To redirect the user to the basic add application page, view the details on this page.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/facebook/facebook-profile-tab-application-fbml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

