<?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>All About LAMP &#187; Facebook Connect</title>
	<atom:link href="http://allaboutlamp.com/tag/facebook-connect/feed/" rel="self" type="application/rss+xml" />
	<link>http://allaboutlamp.com</link>
	<description>Create web applications with Linux, Apache, MySQL, PHP and other open source technologies</description>
	<lastBuildDate>Sun, 08 Jan 2012 15:45:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How does Facebook Connect Authentication work?</title>
		<link>http://allaboutlamp.com/2009/11/how-does-facebook-connect-authentication-work/</link>
		<comments>http://allaboutlamp.com/2009/11/how-does-facebook-connect-authentication-work/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 15:00:58 +0000</pubDate>
		<dc:creator>Daniel Lam</dc:creator>
				<category><![CDATA[Facebook Connect]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[interaction diagram]]></category>

		<guid isPermaLink="false">http://allaboutlamp.com/?p=98</guid>
		<description><![CDATA[Facebook Connect is a mechanism provided by Facebook that lets their users bring their identity and social experience to any website. The first step is authentication - let visitors login to your site with their Facebook accounts. This article explains how that works.]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>Overview</strong></span></p>
<p>Facebook Connect is a mechanism provided by Facebook that lets their users bring their identity and social experience to any website. The first step is authentication &#8211; let visitors login to your site with their Facebook accounts. This article explains how that works.</p>
<p><span style="text-decoration: underline;"><strong>Context</strong></span></p>
<p>This article is for web application developers learning how to implement Facebook Connect authentication in their websites. It is introductory and explains the interaction between the browser, Facebook and your website during authentication. The article also contains references to the sample Facebook Connect web application, <a href="http://www.somethingtoputhere.com/therunaround/demo.tgz">The Turn Around</a>, to point out where the actual function calls are. </p>
<p><span style="text-decoration: underline;"><strong>Solution</strong></span></p>
<p>The authentication process begins when user clicks on the Facebook Connect login button in your website. User will see a pop-up from Facebook and sign in with Facebook account details. Once user logs in, your website can retrieve Facebook user info like profile photo and will be able to write back to Facebook (e.g. publishing feed story in profile) if user grants the required specific permissions.</p>
<p>Exchange of handshakes, credentials, cookies and various function calls occur between the user browser, your website and Facebook server during the authentication process. They are illustrated in the interaction diagram below.</p>
<p><center><br />
<div id="attachment_100" class="wp-caption alignnone" style="width: 260px"><a target="new" href="http://allaboutlamp.com/wp-content/uploads/2009/11/Facebook-Connect-Authentication.gif"><img src="http://allaboutlamp.com/wp-content/uploads/2009/11/Facebook-Connect-Authentication-250x300.gif" alt="Facebook Connect Authentication - Interaction Diagram" title="Facebook Connect Authentication - Interaction Diagram" width="250" height="300" class="size-medium wp-image-100" /></a><p class="wp-caption-text">Facebook Connect Authentication - Interaction Diagram (click to enlarge)</p></div><br />
</center></p>
<ol>
<li>User visits your website.
<li>Your website checks with Facebook to see if user has already signed in using Facebook Connect.
<li>Facebook says no. Using codes in TheRunAround as an example:
<ol type='i'>
<li>index.php &#8211; checks if user has logged in Facebook via User::getLoggedIn()
<li>getLoggedIn() in lib/user.php &#8211; calls facebook_client() and retrieve the facebook user via Facebook::get_loggedin_user()
<li>facebook_client() in lib/fbconnect.php &#8211; creates Facebook object
<li>Constructor in facebook.php (in Facebook PHP library) &#8211; connects to facebook server using api_client, retrieves params via validate_fb_params() but will not get anything. As a result no user will be set
<li>get_loggedin_user() in facebook.php returns null which eventually gets passed back to index.php
	</ol>
<li>Your website returns a page that displays a Connect with Facebook login button. In the sample app, this is done in render_fbconnect_button() in lib/fbconnect.php. Note how the button can be displayed by showing the image directly and calling the FB.Connect.requireSession(), or just by using the <fb:login-button> xFBML syntax.
<li>User clicks on login button. FB.Connect.requireSession() is called
<li>FB.Connect.requireSession() found that user has not logged in Facebook yet and display a &#8220;Connect with Facebook&#8221; pop-up. The pop-up could be in the form of pop-up window or an iFrame window depending on parameters. Note that starting from this step, it is part of the Facebook javascript library and is not open-sourced. Its <a target="new" href="http://wiki.developers.facebook.com/index.php/JavaScript_Client_Library">API</a> is available. This is also an example of the much-discussed <a target="new" href="http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication">&#8220;cross-site scripting&#8221;</a>, as this is a page from your server dynamically loading a script from Facebook server.
<li>User enters Facebook credentials.
<li>Facebook verifies user credentials. Once verified, it calls the javascript callback function registered in waitUntilReady(). The callback function has been registered in facebook_onload() in fbconnect.js.
<li>The callback function in facebook_onload() detects that session status has changed and refresh the page.
<li>Step 1 is repeated again to check if user has logged in to Facebook.
<li>Facebook says yes. User::getLoggedIn() will create and return a user object with a valid Facebook user ID.
<li>Web page displays Facebook content such as profile photo, friends who are also using your website, etc.
</ol>
<p>Once connected, your website will be able to read from and write to the Facebook system on behalf of the logged in user via Facebook API.</p>
<p>Because of the many documents available online and the fact that many of them are outdated, downloading The Run Around sample application and studying it in detail is highly recommended.</p>
<p><span style="text-decoration: underline;"><strong>Reference</strong></span></p>
<ul>
<li><a target="new" href="http://wiki.developers.facebook.com/index.php/Getting_Started_with_Facebook_Connect">http://wiki.developers.facebook.com/index.php/Getting_Started_with_Facebook_Connect</a> &#8211; The beginner&#8217;s guide to Facebook Connect.
<li><a target="new" href="http://wiki.developers.facebook.com/index.php/Using_Facebook_Connect_with_Server-Side_Libraries">http://wiki.developers.facebook.com/index.php/Using_Facebook_Connect_with_Server-Side_Libraries</a> &#8211; Facebook wiki doc explaining how server-side libraries are used.
<li><a target="new" href="http://www.somethingtoputhere.com/therunaround/index.php">The Run Around</a> &#8211; Sample Facebook Connect application provided by Facebook. Its source code is available for <a href="http://www.somethingtoputhere.com/therunaround/demo.tgz">download</a>.
</ul>
]]></content:encoded>
			<wfw:commentRss>http://allaboutlamp.com/2009/11/how-does-facebook-connect-authentication-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why does the basic Facebook Connect example not work?</title>
		<link>http://allaboutlamp.com/2009/11/why-does-the-basic-facebook-connect-example-not-work/</link>
		<comments>http://allaboutlamp.com/2009/11/why-does-the-basic-facebook-connect-example-not-work/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 10:15:38 +0000</pubDate>
		<dc:creator>Daniel Lam</dc:creator>
				<category><![CDATA[Facebook Connect]]></category>
		<category><![CDATA[login]]></category>

		<guid isPermaLink="false">http://allaboutlamp.com/?p=77</guid>
		<description><![CDATA[You are trying to implement Facebook Connect in your site so that your visitors can log in to your site using their Facebook accounts. You followed the simplest example available in 
 <a target="new" href="http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site">a Facebook wiki document</a>, however for some reason the "Connect with Facebook" button does not seem to do anything - no pop-up, no error, nothing. Why is that?
]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>Overview</strong></span></p>
<p>You are trying to implement Facebook Connect in your site so that your visitors can log in to your site using their Facebook accounts. You followed the simplest example available in<br />
 <a target="new" href="http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site">a Facebook wiki document</a>, however for some reason the &#8220;Connect with Facebook&#8221; button does not seem to do anything &#8211; no pop-up, no error, nothing. Why is that?</p>
<p><span style="text-decoration: underline;"><strong>Context</strong></span></p>
<p>This article is for those who want to implement Facebook Connect in their websites. It explains the scenario when a simple Facebook Connect login button does not seem to work.</p>
<p><span style="text-decoration: underline;"><strong>Solution</strong></span></p>
<p>The login button does not do anything most likely because you have not set it up to do anything.</p>
<p>The basic example shown in this Facebook developers wiki page: <a href="http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site">http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site</a> has instructions in great detail, however it has not mentioned clearly that it actually only shows you how to <em>display</em> a Facebook Connect login button.</p>
<p>The test.html described in the wiki page is </p>
<p><code><br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;<br />
&lt;head&gt;&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;fb:login-button&gt;&lt;/fb:login-button&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
    FB.init(&quot;YOUR_API_KEY_HERE&quot;, &quot;xd_receiver.htm&quot;);<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>If all instructions in the wiki page have been followed correctly, clicking on the resultant Connect-with-Facebook login button should trigger a Facebook login form to appear in a pop-up window, <em>given that the user has not logged in to Facebook yet</em>.</p>
<p>If user has logged in to Facebook and clicks on the login button for the first time, a pop-up will appear to ask the user to authorize the integration between your website and Facebook. </p>
<p>Once user logs in via the pop-up window or agrees on the Facebook Connect authorization, clicking on the login button will no longer trigger any actions because user is now &#8220;connected&#8221; and there is no &#8220;callback function&#8221; specified in the html file. </p>
<p>To make it slightly more confusing, the authorization pop-up will only appear once: Even after you clear all the cookies and log out of Facebook in an attempt to start from the beginning, the login button will no longer trigger any actions if you log in Facebook again and click on the test login button. This is because Facebook remembers your authorisation from its servers.</p>
<p>When the wiki page says &#8220;Optionally, you can add a JavaScript handler to the callback function to call when the user logs in&#8221;, it actually meant &#8220;Unless you want user to see no changes after logging in, you need to add a JavaScript handler&#8230;&#8221;.</p>
<p>So how do you specify a &#8220;callback function&#8221; and how does Facebook Authentication work? A separate <a href="http://allaboutlamp.com/2009/11/why-does-the-basic-facebook-connect-example-not-work/">article</a> has been written to answer this question.</p>
]]></content:encoded>
			<wfw:commentRss>http://allaboutlamp.com/2009/11/why-does-the-basic-facebook-connect-example-not-work/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

