<?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; facebook application</title>
	<atom:link href="http://www.stylephp.com/tag/facebook-application/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>A PHP Class For Facebook Application Developer</title>
		<link>http://www.stylephp.com/2009/03/20/a-php-class-for-facebook-application-developer/</link>
		<comments>http://www.stylephp.com/2009/03/20/a-php-class-for-facebook-application-developer/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 20:41:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[facebook application]]></category>
		<category><![CDATA[news feed]]></category>
		<category><![CDATA[profile]]></category>

		<guid isPermaLink="false">http://www.stylephp.com/?p=72</guid>
		<description><![CDATA[You know facebook is a great social application for million of users. And to develop a application for this site is also very popular. So I have planned to write a class where facebook application developer can do most of the basic things for their application using this class.Specially thanks to emran bhai and anis [...]]]></description>
			<content:encoded><![CDATA[<p>You know <a href="http://www.facebook.com/" target="_blank">facebook</a> is a  great social application for million of users. And to develop a application for  this site is also very popular. So I have planned to write a class where  facebook application developer can do most of the basic things for their  application using this class.Specially thanks to <a href="http://www.phpfour.com/" target="_blank">emran bhai</a> and <a href="http://www.ajaxray.com/" target="_blank">anis</a> to review my class.The  basic feature of this class</p>
<ul>
<li><strong>Get Facebook Users profile information </strong></li>
<li><strong>Get Friend list of a facebook user </strong></li>
<li><strong>Send Notification to Facebook user </strong></li>
<li><strong>Send Email Notification to Facebook user </strong></li>
<li><strong>Set Your Application at Facebook user profile page </strong></li>
<li><strong>Publish News feed to Facebook user </strong></li>
</ul>
<p>You can do above all the things to use this Class.</p>
<p><img class="alignnone" src="http://stylephp.com/demo_image/facebook.jpg" alt="" width="678" height="349" /></p>
<p><strong><span style="text-decoration: underline;">Download</span></strong></p>
<p>You can download it from <a href="http://stylephp.com/fbtoolbox/FBToolbox.class.php.zip" target="_blank">here</a>. The zip file contains this class along with an example.  You can also find full documentation here.</p>
<p>You can also download it from <a href="http://www.phpclasses.org/browse/package/5200.html" target="_blank">phpclasses.org</a></p>
<p><strong><span style="text-decoration: underline;">How to use it</span></strong></p>
<div>
<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;">// Include our files</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> include_once (<span style="color: #006080;">'FBToolbox.class.php'</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></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> <span style="color: #008000;">// Prepare the object</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> $fbToolboxObj = <span style="color: #0000ff;">new</span> FBToolbox(<span style="color: #006080;">'YOUR_API_KEY'</span>, <span style="color: #006080;">'YOUR_SECRET_KEY'</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> <span style="color: #008000;">// Get 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;">   9:</span> $userInfo = $fbToolboxObj-&gt;getUserInfo(<span style="color: #006080;">'FB USER ID'</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> <span style="color: #008000;">//print_r($userInfo);</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> echo $userInfo[0][<span style="color: #006080;">'current_location'</span>][<span style="color: #006080;">'city'</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></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> <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;">  14:</span> $friendList = $fbToolboxObj-&gt;getFriendList(<span style="color: #006080;">'FB USER ID'</span>,<span style="color: #0000ff;">false</span>,0,20);</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> <span style="color: #008000;">//print_r($friendList);</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> <span style="color: #008000;">// Send notification</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;">  18:</span> $fbToolboxObj-&gt;sendNotification(array(<span style="color: #006080;">'FB USER ID'</span>),<span style="color: #006080;">'test api class'</span>,<span style="color: #006080;">'app_to_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;">  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> <span style="color: #008000;">// Send email notification (CAUTION: your application must have permission from 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;">  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> $fbToolboxObj-&gt;sendEmail(<span style="color: #006080;">'FB USER ID'</span>,<span style="color: #006080;">'test api class'</span>,<span style="color: #006080;">'test api class'</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> <span style="color: #008000;">// Publish news feed</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> $one_line_story_templates[] = <span style="color: #006080;">'{*actor*} has developed a php wrapper </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> class for facebook application developer.';</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> <span style="color: #008000;">//You have to run this function only one times to get template bundle id</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;">  30:</span> $templateBundleId = $fbToolboxObj-&gt;getTemplateBundleId($one_line_story_templates);</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></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> $fbToolboxObj-&gt;publishNewsFeed(<span style="color: #006080;">'FB USER ID'</span>,$templateBundleId);</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> <span style="color: #008000;">// Add your application to your 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: white;"><span style="color: #606060;">  35:</span> $fbToolboxObj-&gt;addToProfile(<span style="color: #006080;">'FB USER ID'</span>,<span style="color: #006080;">"Wider FbMl"</span>,<span style="color: #006080;">"narrow fbml"</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> ?&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: 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> &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;">  39:</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;">  40:</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>
<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>
</div>
</div>
</div>
</div>
</div>
<p>So devs this is all about my php class. In my next post I will show you how  to develop a facebook application with new platform in details using this class.  Enjoy!!!!
<ul class="related_post">
<li>June 28, 2009 -- <a href="http://www.stylephp.com/2009/06/28/lets-develop-a-facebook-application-part-one/" title="Let&#8217;s Develop a Facebook Application &#8211; Part one">Let&#8217;s Develop a Facebook Application &#8211; Part one (16)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stylephp.com/2009/03/20/a-php-class-for-facebook-application-developer/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
