<?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; interaction diagram</title>
	<atom:link href="http://allaboutlamp.com/tag/interaction-diagram/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>
	</channel>
</rss>

