<?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>Ali Qureshi&#039;s Blog &#187; FBML</title>
	<atom:link href="http://www.parorrey.com/blog/tag/fbml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.parorrey.com/blog</link>
	<description>random bits on web development</description>
	<lastBuildDate>Thu, 09 Sep 2010 10:45:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://www.parorrey.com/blog/?pushpress=hub'/>
		<item>
		<title>Facebook Graph API authentication OAuth 2.0 replacing Require Login</title>
		<link>http://www.parorrey.com/blog/facebook-apps-development/graph-api-authorization-oauth-2-0-replacing-require-login/</link>
		<comments>http://www.parorrey.com/blog/facebook-apps-development/graph-api-authorization-oauth-2-0-replacing-require-login/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 13:27:22 +0000</pubDate>
		<dc:creator>Ali</dc:creator>
				<category><![CDATA[Facebook Apps Development]]></category>
		<category><![CDATA[Facebook Apps]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Graph API]]></category>

		<guid isPermaLink="false">http://www.parorrey.com/blog/?p=120</guid>
		<description><![CDATA[Facebook has recently introduced Graph API and simplified many things. The new Graph API attempts to drastically simplify the way developers read and write data to Facebook.The Graph API uses OAuth 2.0 for authorization. OAuth 2.0 is a simpler version of OAuth that developers used earlier for authorization as $facebook->require_login(). (by the way, old token [...]


Related posts:<ol><li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-applications-will-automatically-upgrade-to-new-data-permissions-on-june-30/' rel='bookmark' title='Permanent Link: Facebook applications will automatically upgrade to new data permissions on June 30'>Facebook applications will automatically upgrade to new data permissions on June 30</a></li>
<li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-requires-every-developer-to-verify-his-facebook-account-to-create-new-applications/' rel='bookmark' title='Permanent Link: Facebook requires every developer to verify his Facebook account to create new applications'>Facebook requires every developer to verify his Facebook account to create new applications</a></li>
<li><a href='http://www.parorrey.com/blog/php-development/how-to-fix-broken-facebook-sample-application-footprints/' rel='bookmark' title='Permanent Link: How to fix broken Facebook sample application &#8216;footprints&#8217;'>How to fix broken Facebook sample application &#8216;footprints&#8217;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Ffacebook-apps-development%2Fgraph-api-authorization-oauth-2-0-replacing-require-login%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Ffacebook-apps-development%2Fgraph-api-authorization-oauth-2-0-replacing-require-login%2F&amp;source=parorrey&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Facebook has recently introduced Graph API and simplified many things.  The new Graph API attempts to drastically simplify the way developers read and write data to Facebook.The Graph API uses <strong>OAuth 2.0 for authorization</strong>. OAuth 2.0 is a simpler version of OAuth that developers used earlier for authorization as <strong>$facebook->require_login().</strong> (by the way, old token still works)</p>
<p>In the previous version, RequireLogin was a one line simple way of getting authorization for user. When I upgraded to OAuth 2.0, I had a hard time getting my user authenticated which looked like very simple thing in pre Graph API days. </p>
<p>Here is how I finally manage to put together for my latest facebook app.</p>
<p>To authenticate user in <strong>Graph API</strong>, first of all, <a href="http://github.com/facebook/php-sdk" target="_blank">download the Facebook PHP SDK</a> facebook.php and put it inside includes folder. After that, get the Application Id, API key, application secret and canvas url of your facebook app and put it inside following $fbconfig array.  </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'appid'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Application id here&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'api'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;API Key here&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;App Secret here&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'canvas_url'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://apps.facebook.com/your_app_name/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
  try<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'includes/facebook.php'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$o</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$o</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create our Application instance.</span>
<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'appId'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'appid'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Your Canvas Callback URL domain here&quot;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$session</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> RequestforPermission<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>	<span style="color: #666666; font-style: italic;">//got session</span>
	try <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$me</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>IsApplicationUser<span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//InsertApplicationUser($me);</span>
            <span style="color: #666666; font-style: italic;">//create a function and insert the user info</span>
             <span style="color: #666666; font-style: italic;">//into App DB for later use</span>
	<span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
 catch <span style="color: #009900;">&#40;</span>FacebookApiException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
RequestforPermission<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fbconfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'canvas_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Please add this function &#8220;RequestforPermission&#8221; as well in this file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> RequestforPermission<span style="color: #009900;">&#40;</span><span style="color: #000088;">$next_url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$loginUrl</span><span style="color: #339933;">=</span><span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'canvas'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'fbconnect'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'display'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'next'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$next_url</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'cancel_url'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'http://www.facebook.com/'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'req_perms'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'email,publish_stream'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;fb:redirect url=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$loginUrl</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end redirect function</span></pre></div></div>

<p>Put all this code into a file named &#8220;fb-authentication.php&#8221; and simply include &#8220;fb-authentication.php&#8221; in those files in your application where you want Facebook user authentication.</p>
<p>Hope that helps.</p>
<p>Cheers. </p>
<div style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;;">
										<iframe
											style="height:25px !important; border:none !important; overflow:hidden !important; width:340px !important;" frameborder="0" scrolling="no" allowTransparency="true"
											src="http://www.linksalpha.com/social?link=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Ffacebook-apps-development%2Fgraph-api-authorization-oauth-2-0-replacing-require-login%2F&fc=333333&fs=arial&fblname=like">
										</iframe>
										</div>

<p>Related posts:<ol><li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-applications-will-automatically-upgrade-to-new-data-permissions-on-june-30/' rel='bookmark' title='Permanent Link: Facebook applications will automatically upgrade to new data permissions on June 30'>Facebook applications will automatically upgrade to new data permissions on June 30</a></li>
<li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-requires-every-developer-to-verify-his-facebook-account-to-create-new-applications/' rel='bookmark' title='Permanent Link: Facebook requires every developer to verify his Facebook account to create new applications'>Facebook requires every developer to verify his Facebook account to create new applications</a></li>
<li><a href='http://www.parorrey.com/blog/php-development/how-to-fix-broken-facebook-sample-application-footprints/' rel='bookmark' title='Permanent Link: How to fix broken Facebook sample application &#8216;footprints&#8217;'>How to fix broken Facebook sample application &#8216;footprints&#8217;</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.parorrey.com/blog/facebook-apps-development/graph-api-authorization-oauth-2-0-replacing-require-login/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FBJS Quick Jump Menu for a FBML Facebook Platform App</title>
		<link>http://www.parorrey.com/blog/php-development/fbjs-quick-jump-menu-for-a-fbml-facebook-platform-app/</link>
		<comments>http://www.parorrey.com/blog/php-development/fbjs-quick-jump-menu-for-a-fbml-facebook-platform-app/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 14:30:20 +0000</pubDate>
		<dc:creator>Ali</dc:creator>
				<category><![CDATA[Facebook Apps Development]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Facebook Apps]]></category>
		<category><![CDATA[FBJS]]></category>
		<category><![CDATA[FBML]]></category>

		<guid isPermaLink="false">http://www.parorrey.com/blog/?p=81</guid>
		<description><![CDATA[In a FBML Facebook App, your quick jump menu will require a little tweak to work in FBJS properly. Just change your standard js jump menu from: &#60;select onchange=&#34;goto(this.options[this.selectedIndex].value)&#34;&#62; &#60;option value=&#34;page.php?id=1&#34;&#62;Page1&#60;/option&#62; &#60;option value=&#34;page.php?id=2&#34;&#62;Page2&#60;/option&#62; &#60;option value=&#34;page.php?id=3&#34;&#62;Page3&#60;/option&#62; &#60;/select&#62; To this: &#60;select onchange=&#34;document.setLocation(this.getValue());&#34;&#62; &#60;option value=&#34;page.php?id=1&#34;&#62;Page1&#60;/option&#62; &#60;option value=&#34;page.php?id=2&#34;&#62;Page2&#60;/option&#62; &#60;option value=&#34;page.php?id=3&#34;&#62;Page3&#60;/option&#62; &#60;/select&#62; Cheers. Related posts:Facebook requires every developer to verify [...]


Related posts:<ol><li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-requires-every-developer-to-verify-his-facebook-account-to-create-new-applications/' rel='bookmark' title='Permanent Link: Facebook requires every developer to verify his Facebook account to create new applications'>Facebook requires every developer to verify his Facebook account to create new applications</a></li>
<li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-applications-will-automatically-upgrade-to-new-data-permissions-on-june-30/' rel='bookmark' title='Permanent Link: Facebook applications will automatically upgrade to new data permissions on June 30'>Facebook applications will automatically upgrade to new data permissions on June 30</a></li>
<li><a href='http://www.parorrey.com/blog/facebook-apps-development/graph-api-authorization-oauth-2-0-replacing-require-login/' rel='bookmark' title='Permanent Link: Facebook Graph API authentication OAuth 2.0 replacing Require Login'>Facebook Graph API authentication OAuth 2.0 replacing Require Login</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Fphp-development%2Ffbjs-quick-jump-menu-for-a-fbml-facebook-platform-app%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Fphp-development%2Ffbjs-quick-jump-menu-for-a-fbml-facebook-platform-app%2F&amp;source=parorrey&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In a <strong>FBML Facebook App</strong>, your quick jump menu will require a little tweak to work in <strong>FBJS</strong> properly.<br />
Just change your standard js jump menu from:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>select onchange<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;goto(this.options[this.selectedIndex].value)&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;page.php?id=1&quot;</span><span style="color: #339933;">&gt;</span>Page1<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;page.php?id=2&quot;</span><span style="color: #339933;">&gt;</span>Page2<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;page.php?id=3&quot;</span><span style="color: #339933;">&gt;</span>Page3<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>select<span style="color: #339933;">&gt;</span></pre></div></div>

<p>To this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>select onchange<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;document.setLocation(this.getValue());&quot;</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;page.php?id=1&quot;</span><span style="color: #339933;">&gt;</span>Page1<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;page.php?id=2&quot;</span><span style="color: #339933;">&gt;</span>Page2<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;page.php?id=3&quot;</span><span style="color: #339933;">&gt;</span>Page3<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>select<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Cheers.</p>
<div style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;;">
										<iframe
											style="height:25px !important; border:none !important; overflow:hidden !important; width:340px !important;" frameborder="0" scrolling="no" allowTransparency="true"
											src="http://www.linksalpha.com/social?link=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Fphp-development%2Ffbjs-quick-jump-menu-for-a-fbml-facebook-platform-app%2F&fc=333333&fs=arial&fblname=like">
										</iframe>
										</div>

<p>Related posts:<ol><li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-requires-every-developer-to-verify-his-facebook-account-to-create-new-applications/' rel='bookmark' title='Permanent Link: Facebook requires every developer to verify his Facebook account to create new applications'>Facebook requires every developer to verify his Facebook account to create new applications</a></li>
<li><a href='http://www.parorrey.com/blog/facebook-apps-development/facebook-applications-will-automatically-upgrade-to-new-data-permissions-on-june-30/' rel='bookmark' title='Permanent Link: Facebook applications will automatically upgrade to new data permissions on June 30'>Facebook applications will automatically upgrade to new data permissions on June 30</a></li>
<li><a href='http://www.parorrey.com/blog/facebook-apps-development/graph-api-authorization-oauth-2-0-replacing-require-login/' rel='bookmark' title='Permanent Link: Facebook Graph API authentication OAuth 2.0 replacing Require Login'>Facebook Graph API authentication OAuth 2.0 replacing Require Login</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.parorrey.com/blog/php-development/fbjs-quick-jump-menu-for-a-fbml-facebook-platform-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
