<?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>Raju Mazumder &#187; fbjs</title>
	<atom:link href="http://www.stylephp.com/tag/fbjs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stylephp.com</link>
	<description>TDD, Agile and Open Source Enthusiastic</description>
	<lastBuildDate>Mon, 29 Jun 2009 17:36:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Let&#8217;s Develop a Facebook Application &#8211; Part one</title>
		<link>http://www.stylephp.com/2009/06/28/lets-develop-a-facebook-application-part-one/</link>
		<comments>http://www.stylephp.com/2009/06/28/lets-develop-a-facebook-application-part-one/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 18:44:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[facebook application development]]></category>
		<category><![CDATA[fbjs]]></category>
		<category><![CDATA[feed form dialog]]></category>
		<category><![CDATA[notification]]></category>

		<guid isPermaLink="false">http://www.stylephp.com/2009/06/28/lets-develop-a-facebook-application-part-one/</guid>
		<description><![CDATA[Hi Guys you know Facebook is popular platform where thousands of developer working to develop application for facebook users.It is very easy to develop facebook application.Here I will show you how to develop a facebook application.I have divided it into five parts.At the end of every part you will get a demo of application which [...]]]></description>
			<content:encoded><![CDATA[<p>Hi Guys you know <a href="http://www.facebook.com/">Facebook</a> is popular platform where thousands of developer working to develop application for facebook users.It is very easy to develop facebook application.Here I will show you how to develop a facebook application.I have divided it into five parts.At the end of every part you will get a demo of application which you can test to keep it to your server.</p>
<p>Before we begin, there are a few things you need to know. In order to create a Facebook application, you should know or need the following:</p>
<ul>
<li>You should be well versed in PHP or some other scripting language — such as ASP.NET , Ruby on Rails, JavaScript, or Python — especially one that has a client library for Facebook API.</li>
<li>You need to have a basic understanding of the Internet, SSH, MySQL, and Unix</li>
<li>You need to be familiar with Web hosting fundamentals and have a place to host your application.</li>
</ul>
<p>Now you're ready to get started! You can read in depth instructions on the <a href="http://wiki.developers.facebook.com/index.php/Creating_Your_First_Application">Facebook Developers Wiki</a>, but this outline here should give you good enough idea to get you going.</p>
<p><strong><span style="font-size: small;">Here are the summary of <span style="color: #0000ff;">part one</span></span></strong></p>
<ul>
<li><strong>Application Overview </strong></li>
<li><strong>Setting up  an environment for our application. </strong></li>
<li><strong>Initialize our application or Setup our Application. </strong></li>
<li><strong>Display " Welcome to Our Application" </strong></li>
<li><strong>Add our applicaton to user profile page </strong></li>
<li><strong>Get User information </strong></li>
<li><strong>Get user friends list </strong></li>
<li><strong>Send Invitation to friends</strong></li>
<li><strong>Send Notification to friends </strong></li>
<li><strong>Send Notification Email to friends </strong></li>
<li><strong>publish News Feed to Friends Wall using Feed Form Dialog </strong></li>
</ul>
<p><strong><span style="color: #0000ff;">Part Two</span></strong></p>
<ul>
<li><strong><span style="color: #808080;">Facebook Connect</span></strong></li>
<li><strong><span style="color: #808080;">Multi friend Selector</span></strong></li>
<li><strong><span style="color: #808080;">Ajax with FBJS</span></strong></li>
</ul>
<p><strong><span style="font-size: large;"><span style="text-decoration: underline;">Application Overview</span></span></strong></p>
<p>First of all see a screen shot of our application and add the application. the url is</p>
<p><a title="http://apps.facebook.com/guessthecelebrity/index.php" href="http://apps.facebook.com/guessthecelebrity/index.php"><strong>http://apps.facebook.com/guessthecelebrity/index.php</strong></a></p>
<p>You can download the application until welcome page from <a href="http://stylephp.com/guessthecelebrity/download/guessthecelebrity_welcome.rar" target="_blank"><strong>here</strong></a></p>
<p>And you can download the whole application from <a href="http://stylephp.com/guessthecelebrity/download/guessthecelebrity_final.rar" target="_blank"><strong><span style="font-size: x-small;">here</span></strong></a></p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/application-demo.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="application_demo" src="http://www.stylephp.com/wp-content/uploads/2009/06/application-demo-thumb.png" border="0" alt="application_demo" width="540" height="340" /></a></p>
<p>We will develop a simple funny celebrity contest application where every user can participate and can invite their friends.</p>
<p><strong>Guess Celebrity</strong></p>
<p>This is the page where user can play with celebrity.<br />
<strong></strong></p>
<p><strong>Invite Friends</strong></p>
<p>We can invite friends to join to this application.</p>
<p><span style="font-size: large;"><strong><span style="text-decoration: underline;">Setting up an environment for our application</span></strong></span></p>
<p>Now you have to create folder where you want to keep your application like where you want to host your application.I have created a folder "guessthecelebrity" as our application name.So you can also create a folder like your application name or  any name. I have given a screenshot of our application's folder structure here. So you can understand it easily.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/application-structure.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="application_structure" src="http://www.stylephp.com/wp-content/uploads/2009/06/application-structure-thumb.png" border="0" alt="application_structure" width="591" height="172" /></a></p>
<p>You can download php 5 client library from <a href="http://wiki.developers.facebook.com/index.php/Client_Libraries">http://wiki.developers.facebook.com/index.php/Client_Libraries</a></p>
<p>And You can download database library ezsql class from <a href="http://php.justinvincent.com">http://php.justinvincent.com</a></p>
<p>So I think you have a directory structure into your server. Here I will use my FBToolbox class to make this application.Because in this class most of the basic things are already handle. Let's start our coding.</p>
<p><strong><span style="font-size: small;">Step 1</span></strong></p>
<p>open your favorite editor and create a php file.name it <strong><span style="color: #ff0000;">config.php</span></strong> where we will write all configuration settings.</p>
<div>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> <span style="color: #008000">// Facebook-specific configuration</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span> $apiKey         = <span style="color: #006080">'################################'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span> $secretKey      = <span style="color: #006080">'################################'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span> $baseUrl        = <span style="color: #006080">'http://apps.facebook.com/guessthecelebrity/'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span> $callbackUrl    = <span style="color: #006080">'http://www.stylephp.com/guessthecelebrity/'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   9:</span> <span style="color: #008000">// Database configuration</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  10:</span> $dbconfig[<span style="color: #006080">'db'</span>]     = <span style="color: #006080">'YOUR DATABASE NAME'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  11:</span> $dbconfig[<span style="color: #006080">'host'</span>]   = <span style="color: #006080">'YOUR DATABASE HOST'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  12:</span> $dbconfig[<span style="color: #006080">'user'</span>]   = <span style="color: #006080">'DB USER'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  13:</span> $dbconfig[<span style="color: #006080">'pass'</span>]   = <span style="color: #006080">'DB PASSWORD'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  14:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  15:</span> $listPerPage         = 10;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  16:</span> $totalSearchResult    = 0;</pre>
</div>
</div>
<p>After setting up our application we will initialize our api and secret key. right now just keep it what I am writing here. And change the database settings as your database configuration and save this file at <strong>guessthecelebrity</strong> folder.</div>
<div><strong><span style="font-size: small;">Step 2</span></strong></div>
<div>Now create another one file and name it <strong><span style="color: #ff0000;">common.php</span></strong> where we will keep our database related code and some common function.</div>
<div><strong> <span style="color: #404040;">You can download the common.php file from </span></strong><a href="http://stylephp.com/guessthecelebrity/download/common.rar" target="_blank"><strong><span style="font-size: x-small;">here</span></strong></a>.</div>
<div>Here you see a function <strong>getRequestFileName()</strong> which I will use to get file name and select correct tab.</div>
<div><strong><span style="font-size: small;">Step 3</span></strong></div>
<div><strong></strong></div>
<div><strong></strong></div>
<div>Now copy my <strong><span style="color: #ff0000; font-size: x-small;">FBToolbox class</span></strong> into your folder. I have changed some code there to use it with a application.</div>
<div>So you better copy this code or download the class from here.</div>
<div><strong><span style="color: #404040; font-size: x-small;">You can download FBToolbox class from </span><a title="FBToolbox class" href="http://stylephp.com/guessthecelebrity/download/FBToolbox.class.rar" target="_blank"><span style="color: #000080; font-size: x-small;">here</span></a></strong></div>
<div><strong></strong></div>
<div><strong></strong></div>
<div><strong></strong></div>
<div><strong></strong></div>
<div><strong></strong></div>
<div><strong><span style="color: #808080; font-size: small;">Step 4</span></strong></div>
<p>Now create another one file and name it <strong><span style="color: #ff0000;">header.php</span></strong> where we will keep our header and menu portion. And also we will keep our css and JavaScript code at this file.In this file there are two tab one is <strong>Guess Celebrity</strong> and other one is <strong>invite friends</strong>.If you want you can create another  tab.There are some css code also for some style.</p>
<p><strong><span style="color: #404040;">You can download header.php file from</span></strong> <a href="http://stylephp.com/guessthecelebrity/download/header.rar" target="_blank"><strong><span style="font-size: x-small;">here</span></strong></a></p>
<p><span><strong>Step 5</strong></span></p>
<p><span style="font-size: small;"><span style="font-size: x-small;">Create another one file and name it <strong>index.php</strong> which is home page of our application</span><strong>.</strong></span><span style="font-size: x-small;">Where we include two file one is <strong>FBToolbox class</strong> and another one is <strong>common.php.</strong> And also <strong>footer.php</strong> file. In this page we will just welcome message to the user.So first we get user id using FBToolbox class function <strong>getUserID().</strong></span></p>
<div>
<div><strong><span style="color: #404040;">You can download index.php file from</span></strong> <a href="http://stylephp.com/guessthecelebrity/download/index.rar" target="_blank"><strong><span style="font-size: x-small;">here</span></strong></a></div>
</div>
<p><strong><span style="font-size: small;">step 6</span></strong></p>
<p><span style="font-size: x-small;">Create another one file and name it <strong><span style="color: #ff0000;">footer.php</span></strong> where we will keep our footer information there.</span></p>
<p><span style="font-size: x-small;"><strong><span style="color: #404040;">You can download footer.php file from</span></strong> </span><a href="http://stylephp.com/guessthecelebrity/download/footer.rar" target="_blank"><strong><span style="font-size: x-small;">here</span></strong></a><strong><span style="font-size: x-small;">.</span></strong></p>
<p><span style="color: #004000; font-size: x-small;">OK That’s good,We have completed our environment to develop facebook application!!!!!!</span></p>
<p><strong><span style="text-decoration: underline;"><span style="font-size: large;">Initialize our application or Setup our Application</span></span></strong></p>
<p><strong></strong></p>
<p><span style="font-size: small;"><strong>step 1 </strong></span></p>
<p><span style="font-size: small;"><span style="font-size: x-small;">Now click on this </span><a title="http://www.facebook.com/developers/" href="http://www.facebook.com/developers/" target="_blank"><span style="font-size: x-small;">http://www.facebook.com/developers/</span></a><span style="font-size: x-small;"> to set up an application</span><strong>.</strong></span></p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/setup-app1.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="setup_app" src="http://www.stylephp.com/wp-content/uploads/2009/06/setup-app-thumb1.png" border="0" alt="setup_app" width="526" height="231" /></a></p>
<p><strong></strong></p>
<p><span style="font-size: x-small;">Here you will see a button <strong>set up new application</strong>. Please click on this button.</span></p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/application-setup11.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="application_setup1" src="http://www.stylephp.com/wp-content/uploads/2009/06/application-setup1-thumb1.png" border="0" alt="application_setup1" width="527" height="222" /></a></p>
<p>You will get this screen.where You have to type your <strong>application name</strong> and select <strong>agree</strong> and then click on <strong>save changes</strong> button.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/applicaltion-setup21.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="applicaltion_setup2" src="http://www.stylephp.com/wp-content/uploads/2009/06/applicaltion-setup2-thumb1.png" border="0" alt="applicaltion_setup2" width="526" height="253" /></a></p>
<p>You will get your API and Secret Key.If you want you can change icon and logo also to click on change your icon and change your logo link.Now click on Authentication Tab.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/step41.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="step4" src="http://www.stylephp.com/wp-content/uploads/2009/06/step4-thumb1.png" border="0" alt="step4" width="521" height="234" /></a></p>
<p>Here you can check users and Facebook Pages.So user can add your application. Then click on User Profiles Tab.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/application-setup32.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="application_setup3" src="http://www.stylephp.com/wp-content/uploads/2009/06/application-setup3-thumb2.png" border="0" alt="application_setup3" width="508" height="196" /></a></p>
<p>Here you can write tab Name and tab url.Which will show users profile tab. And you can select wide or narrow for your application.Then click on Canvas page Tab.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/application-setup41.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="application_setup4" src="http://www.stylephp.com/wp-content/uploads/2009/06/application-setup4-thumb1.png" border="0" alt="application_setup4" width="514" height="220" /></a></p>
<p>Here write a unique name for your canvas page.If your application name exists then it will show a error message.so write again.</p>
<p>ooh!! we have finished setup for our application. That’s good.</p>
<p><strong><span style="text-decoration: underline;"><span style="font-size: large;">Display Welcome to Our Application</span></span></strong></p>
<p><strong></strong></p>
<p><strong><span style="font-size: small;">Step 1</span></strong></p>
<p><span style="font-size: x-small;">Now open the config.php file again. And change the <strong>Api key</strong>, <strong>Secret Key</strong>,<strong>baseUrl</strong> and <strong>callbackUrl</strong>. <strong>baseUrl</strong> is the canvas page url and <strong>callbackUrl</strong> is the location of file at your server. You can see this information from <a title="http://www.facebook.com/developers/" href="http://www.facebook.com/developers/">http://www.facebook.com/developers/</a> link.</span></p>
<p><span style="font-size: x-small;"><strong>Step 2</strong></span></p>
<p><strong><span style="font-size: x-small;">Now all are set. You have to run this application using base or canvas url. Like you can run my application to type <a title="http://apps.facebook.com/jokesforyou/" href="http://apps.facebook.com/guessthecelebrity/">http://apps.facebook.com/guessthecelebrity/</a></span></strong></p>
<p><span style="color: #004000; font-size: small;"><strong>Untill Now You can download the application from <a title="First part of our application" href="http://stylephp.com/guessthecelebrity/download/guessthecelebrity_welcome.rar" target="_blank">here</a></strong></span></p>
<p><strong><span style="text-decoration: underline;"><span style="font-size: large;">Add Our Application to User Profile Page</span></span></strong></p>
<p><span style="font-size: x-small;">Now open the <strong>index.php</strong> file again. And Add below these line.</span></p>
<div>
<div>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> <span style="color: #008000">//add this application to user profile</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span> $boxFbml = <span style="color: #006080">"Guess the Celebrity Contest..&lt;a href="</span>.$baseUrl.<span style="color: #006080">"&gt; Join Now"</span>.<span style="color: #006080">"&lt;/a&gt;"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span> $wallFbml = <span style="color: #006080">"Guess the Celebrity Contest..&lt;a href="</span>.$baseUrl.<span style="color: #006080">"&gt; Join Now"</span>.<span style="color: #006080">"&lt;/a&gt;"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span> $fbToolboxObj-&gt;addToProfile($fbuser, $boxFbml, $wallFbml);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span> &lt;!-- you have to print <span style="color: #0000ff">this</span> line to add application to user profile</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   9:</span>      <span style="color: #0000ff">if</span> user click on addtoprofile link then above function will work --&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  10:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  11:</span> &lt;div <span style="color: #0000ff">class</span>=<span style="color: #006080">"section_button"</span>&gt;&lt;fb:add-section-button section=<span style="color: #006080">"profile"</span>/&gt;&lt;/div&gt;</pre>
</div>
</div>
</div>
</div>
<p><strong><span style="color: #404040;">Or you can download the file from</span></strong> <a href="http://stylephp.com/guessthecelebrity/download/index_profile.rar" target="_blank"><strong>here</strong></a></p>
<p><strong><span style="text-decoration: underline;"><span style="font-size: large;">Get User Information</span></span></strong></p>
<p><span style="font-size: x-small;">By getting user information from facebook we will save it to our database. So we have to create a database.I have created a database named ‘<strong>guessthecelebrity’.</strong> You can download the schema from <strong><a title="Database schema" href="http://stylephp.com/guessthecelebrity/download/schema.rar" target="_blank">here</a></strong>. And Add some function at <strong>common.php </strong>file like saveUserInfo(),getUserInfo() etc.</span></p>
<p><span style="font-size: x-small;"><strong>You can download this file from</strong> <a href="http://stylephp.com/guessthecelebrity/download/common_final.rar" target="_blank"><strong>here</strong></a>.</span></p>
<div>And then open <strong>index.php</strong> file again and add these line.</div>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> $userInfo = getUserInfo($fbuser);<span style="color: #008000">//get user information from our db</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span> <span style="color: #0000ff">if</span>(!$userInfo)<span style="color: #008000">//if not found</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span> {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span>     $user_details = $fbToolboxObj-&gt;getUserInfo($fbuser);<span style="color: #008000">//get from facebook</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span>     saveUserInfo($fbuser,$user_details);<span style="color: #008000">//save user information</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span>     $userInfo = getUserInfo($fbuser);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span> }</pre>
</div>
</div>
<div><strong>Or you can download the file from</strong> <a href="http://stylephp.com/guessthecelebrity/download/index_user.rar" target="_blank"><strong>here</strong></a></div>
<p><strong></strong></p>
<p><strong><span style="text-decoration: underline;"><span style="font-size: large;">Get User FriendList and Send Invitation</span></span></strong></p>
<p><span style="font-size: x-small;">Here we will create a invitation page.where user can send invitation to their friends. Create a file named <strong>invite.php</strong> or you can download this file from here.In this page we take users friend list using my FBToolbox class and send invitation to those friends. For invitation you have to pass <strong>addurl</strong> and <strong>nextUrl</strong> and <strong>fbmlData</strong>.Here addUrl is when user accept your invitation where they have to go and nextUrl is when user send invitation then where he will go after submit invitation. And fbmlData is your message for your friend.</span></p>
<p><span style="font-size: x-small;"><strong>You can download this file from</strong> <a href="http://stylephp.com/guessthecelebrity/download/invite.rar" target="_blank"><strong>here</strong></a>.</span></p>
<p><strong><span style="font-size: large;"><span style="text-decoration: underline;">Publish News Feed Using Feed Form Dialog:</span></span></strong></p>
<p>We will create feed template to publish news feed at user’s News feed section.So first of all go to this link <a title="http://developers.facebook.com/tools.php?feed" href="http://developers.facebook.com/tools.php?feed">http://developers.facebook.com/tools.php?feed</a> and you will see below page.select your application and click next.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/feed11.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="feed1" src="http://www.stylephp.com/wp-content/uploads/2009/06/feed1-thumb1.png" border="0" alt="feed1" width="517" height="204" /></a></p>
<p>then you will another one window where you can write one line template.see the picture below. change the highlighted color text as you see here.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/feed21.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="feed2" src="http://www.stylephp.com/wp-content/uploads/2009/06/feed2-thumb1.png" border="0" alt="feed2" width="519" height="223" /></a></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong>One line feed :</strong> {*actor*}'s guess is this is &lt;a href="{*contest-url*}"&gt;{*celebrity-name*}'s&lt;/a&gt; photo. If you want to participate or to help your friend &lt;a href="{*contest-url*}"&gt;click here&lt;/a&gt;</p>
<p><strong>Sample Data : </strong></p>
<p>{"contest-url":"<a href="http://stylephp.com&quot;">http://stylephp.com"</a>,</p>
<p>"celebrity-name":"Raju Mazumder"</p>
<p>}</p>
<p>and click next and you will see another one window.see the picture below and change the highlighted color text as you see here.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/feed31.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="feed3" src="http://www.stylephp.com/wp-content/uploads/2009/06/feed3-thumb1.png" border="0" alt="feed3" width="521" height="222" /></a></p>
<p><strong>short story template:</strong> {*actor*}'s guess is this is &lt;a href="{*contest-url*}"&gt;{*celebrity-name*}'s&lt;/a&gt; photo. If you want to participate or to help your friend &lt;a href="{*contest-url*}"&gt;click here&lt;/a&gt;</p>
<p><strong>short story template body </strong>: {*body-text*}</p>
<p><strong>sample data: </strong></p>
<p>{"contest-url":"<a href="http://stylephp.com&quot;">http://stylephp.com"</a>,</p>
<p>"celebrity-name":"Raju Mazumder",</p>
<p>"body-text":"Guess the celebrity contest",</p>
<p>"images":[{"src":"<a href="http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg&quot;,&quot;href&quot;:&quot;http://www.facebook.com&quot;}]">http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg","href":"http://www.facebook.com"}]</a></p>
<p>}</p>
<p>And then click next and you will the picture below.</p>
<p><a href="http://www.stylephp.com/wp-content/uploads/2009/06/feed41.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="feed4" src="http://www.stylephp.com/wp-content/uploads/2009/06/feed4-thumb1.png" border="0" alt="feed4" width="534" height="224" /></a></p>
<p><strong>Action Link text:</strong> read more</p>
<p><strong>Action Link Url </strong>: {*contest-url*}</p>
<p><strong>Sample Template Data:</strong></p>
<p>{"contest-url":"<a href="http://stylephp.com&quot;">http://stylephp.com"</a>,</p>
<p>"celebrity-name":"Raju Mazumder",</p>
<p>"body-text":"Guess the celebrity contest",</p>
<p>"images":[{"src":"<a href="http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg&quot;,&quot;href&quot;:&quot;http://www.facebook.com&quot;}]">http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg","href":"http://www.facebook.com"}]</a></p>
<p>}</p>
<p>And then click next you will see another one window.click on Register Template Bundle to get template bundle id and save it to use with our application.</p>
<p>ooh great we have created our feed template. Now lets see how to use it into our application.</p>
<p>Open <strong>header.php </strong>file agian and write these line below.here you have to change template bundle id which I use here.Use your register template bundle id. I have used ajax here to submit user celebrity guess selection.</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> &lt;script&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span> function publishNewsFeed(celebrityPhoto,facebookuid,infoDiv,contestId,action)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span> {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span>         var celebrityName = <span style="color: #006080">''</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span>         var answerObj = <span style="color: #006080">''</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span>         var answer = <span style="color: #006080">''</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span>         <span style="color: #0000ff">for</span>(var i = 0; i &lt; 4; i++)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   9:</span>         {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  10:</span>             answerObj = document.getElementById(<span style="color: #006080">"answer"</span>+i);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  11:</span>             <span style="color: #0000ff">if</span>(answerObj.getChecked())</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  12:</span>             {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  13:</span>                 celebrityName = answerObj.getTitle();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  14:</span>                 answer = answerObj.getValue();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  15:</span>             }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  16:</span>         }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  17:</span>         document.getElementById(<span style="color: #006080">'display'</span>).setValue(answerObj);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  18:</span>         <span style="color: #0000ff">if</span>(celebrityPhoto != <span style="color: #006080">''</span>)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  19:</span>         {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  20:</span>             src = <span style="color: #006080">"&lt;?php echo $callbackUrl;?&gt;images/celebrity/"</span>+celebrityPhoto;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  21:</span>         }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  22:</span>         <span style="color: #0000ff">else</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  23:</span>         {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  24:</span>             src = <span style="color: #006080">"&lt;?php echo $callbackUrl?&gt;images/banner.jpg"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  25:</span>         }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  26:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  27:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  28:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  29:</span>         var template_data = {<span style="color: #006080">"celebrity-name"</span> : <span style="color: #006080">""</span>+celebrityName,</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  30:</span>         <span style="color: #006080">"contest-url"</span>: <span style="color: #006080">"&lt;?php echo $baseUrl?&gt;"</span>,</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  31:</span>         <span style="color: #006080">"body-text"</span>:<span style="color: #006080">"Guess Celebrity Contest"</span>,</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  32:</span>         <span style="color: #006080">"images"</span>:[{<span style="color: #006080">"src"</span>:src,<span style="color: #006080">"href"</span>:<span style="color: #006080">"&lt;?php echo $baseUrl?&gt;"</span>}]};</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  33:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  34:</span>         Facebook.showFeedDialog(<strong><span style="color: #ff0000;">83607323911</span></strong>, template_data, <span style="color: #006080">''</span>, [],</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  35:</span>                           function() {<span style="color: #0000ff">new</span> Dialog().showMessage(<span style="color: #006080">"Info"</span>,</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  36:</span>                 <span style="color: #006080">"Successfully shared your answer with your friends"</span>);});</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  37:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  38:</span>         var ajax            = <span style="color: #0000ff">new</span> Ajax();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  39:</span>         ajax.responseType   = Ajax.FBML;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  40:</span>         ajax.ondone         = function(data)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  41:</span>         {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  42:</span>             document.getElementById(infoDiv).setInnerFBML(data);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  43:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  44:</span>         }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  45:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  46:</span>         var queryParams     = {<span style="color: #006080">"answer"</span> : answer, <span style="color: #006080">"facebookuid"</span> : facebookuid,</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  47:</span>         <span style="color: #006080">"contestId"</span> : contestId};</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  48:</span>         ajax.post(<span style="color: #006080">'&lt;?php echo $callbackUrl ?&gt;ajax.php?action='</span>+action, queryParams);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  49:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  50:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  51:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  52:</span> }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  53:</span> &lt;/script&gt;</pre>
</div>
</div>
<p>And for this you have to change <strong>index.php</strong> file also.You can download the complete index.php file from here. And Here we have to create another file ajax.php which file will handle all ajax request from our application.</p>
<p><strong>You can download the</strong> <strong><a href="http://stylephp.com/guessthecelebrity/download/ajax.rar" target="_blank">ajax.php</a></strong> <strong>and</strong> <strong><a href="http://stylephp.com/guessthecelebrity/download/header_final.rar" target="_blank">header.php</a></strong> <strong>file from here.</strong></p>
<div><strong><span style="font-size: large;"><span style="text-decoration: underline;">Send Notification:</span></span></strong></div>
<p>Now we will send notification to user’s friend when a user added our application. Open <strong>index.php</strong> file again write these line.</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> <span style="color: #008000">//send Notification and Notification Email</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span> <span style="color: #008000">// Get friend list here</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span> $friendList = $fbToolboxObj-&gt;getFriendList($fbuser,<span style="color: #0000ff">false</span>);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span> $message =  <span style="color: #006080">'&lt;fb:name uid='</span>.$fbuser.<span style="color: #006080">' capitalize="true" /&gt; </span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span>             has added Guess the Celebrity Application. If you</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span>             want you can join to click &lt;a href='.$baseUrl.<span style="color: #006080">'&gt;here&lt;/a&gt;'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   9:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  10:</span> $fbToolboxObj-&gt;sendNotification($friendList,$message,<span style="color: #006080">'app_to_user'</span>);</pre>
</div>
</div>
<p><strong>Or you can download from</strong> <a href="http://stylephp.com/guessthecelebrity/download/index_final.rar" target="_blank"><strong>here</strong></a></p>
<p>Oh great we have completed our application’s  part one</p>
<p><strong><span style="color: #004000; font-size: small;">You can download the whole application to click</span></strong> <a href="http://stylephp.com/guessthecelebrity/download/guessthecelebrity_final.rar" target="_blank"><strong><span style="font-size: small;">here</span></strong></a></p>
<p>So Develop facebook application and enjoy!!!</p>
<p>Let me know if you want to know anything.</p>
<p><strong>My next post about this application’s second part where I will show you facebook connect,multi friend selector and more!! so keep your eyes here…..</strong>
<ul class="related_post">
<li>March 20, 2009 -- <a href="http://www.stylephp.com/2009/03/20/a-php-class-for-facebook-application-developer/" title="A PHP Class For Facebook Application Developer">A PHP Class For Facebook Application Developer (15)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stylephp.com/2009/06/28/lets-develop-a-facebook-application-part-one/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>
