<?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>Facebook Cookbook</title>
	<atom:link href="http://fbcookbook.ofhas.in/feed/" rel="self" type="application/rss+xml" />
	<link>http://fbcookbook.ofhas.in</link>
	<description>thousands of app development recipes</description>
	<lastBuildDate>Sat, 26 Sep 2009 16:51:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>how to  trigger multiple onload functions when divs  are  loaded by FBJS</title>
		<link>http://fbcookbook.ofhas.in/2009/02/15/how-to-trigger-multiple-onload-functions-when-divs-are-loaded-by-fbjs/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/15/how-to-trigger-multiple-onload-functions-when-divs-are-loaded-by-fbjs/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 16:56:12 +0000</pubDate>
		<dc:creator>Saidur Rahman</dc:creator>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[FBJS]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=275</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/15/how-to-trigger-multiple-onload-functions-when-divs-are-loaded-by-fbjs/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to  trigger multiple onload functions when divs  are  loaded by FBJS';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>




  
facing trouble to trigger multiple onload event to work  FBJS does not allow acess to the window object. So how can onload event fire when &#60;div&#62; is loaded on canvas. also FBJS is executed after the entire page has been loaded. so really shouldn&#8217;t matter where you call the function within your [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/15/how-to-trigger-multiple-onload-functions-when-divs-are-loaded-by-fbjs/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to  trigger multiple onload functions when divs  are  loaded by FBJS';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><span class="mceItemObject"   classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></span> <mce:style><!  st1\:*{behavior:url(#ieooui) } --> <!--[endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-language:AR-SA;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]> <mce:style><!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p class="MsoNormal">facing trouble to trigger multiple onload event to work <span> </span>FBJS does not allow acess to the window object. So how can onload event fire when &lt;div&gt;<span> </span>is loaded on canvas. also FBJS is executed after the entire page has been loaded. so really shouldn&#8217;t matter where you call the function within your canvas page file. however let’s see how can we trigger on load for multiple div.</p>
<p class="MsoNormal">
<p class="MsoNormal">In this example we create two div which load by onload. One &lt;div=’msg’&gt; is for content a message and another &lt;div=’ ajax’&gt; which load the value by ajax way.</p>
<p class="MsoNormal">
<p class="MsoNormal"><span> </span>For that reason in FBJS we create a varraible <span> </span>array and pushing <span> </span>two functions on that array variable.</p>
<pre name="code" class="php">

var onload = [];

onload.push(function() {
//ONLOAD STUFFS HERE
msg_laod();
do_ajax();

});

&lt;/script&gt;
</pre>
<p class="MsoNormal">now we define the two functions. The message load function just simply display a text message on &lt;div id=’msg’&gt;. and do_ajax() function display the value by ajax call.</p>
<p class="MsoNormal">
<pre name="code" class="php">

&lt;script&gt;
function msg_laod()
{
document.getElementById(&#039;msg&#039;).setInnerHTML(&#039;test message content&#039;);

}

function do_ajax()
{
var ajax = new Ajax();
ajax.ondone = function(data) {
document.getElementById(&#039;req&#039;).setInnerFBML(data);
}
ajax.requireLogin = 1;
ajax.responseType = Ajax.FBML;
ajax.post(&#039;http://www.techsmashing.com/banglakeyboard/adduser.php&#039;);
}            ajax.post(.....display.php&#039;); // ajax callback url
}&lt;/script&gt;
</pre>
<p class="MsoNormal">
<p class="MsoNormal">now we trigger on the onload event . by pushing functions into an array and executing them at the bottom of the page it ensures that the elements are indeed in the dom tree.  here we add setTimeout function to to make sure the browser is fully loaded. It allows 100 miliseconds. because the rest of the page to load (facebook footer and such).   increasing the 100 milisecond limit can solve some of these problems.</p>
<p class="MsoNormal">
<p class="MsoNormal">
<pre name="code" class="php">
&lt;/p&gt;&lt;/p&gt;

&lt;script&gt;
//the very last thing on the page
setTimeout (function() {
for(var a = 0;a &lt; onload.length;a++) {onload[a]();}
}, 100);
&lt;/script&gt;
</pre>
<p class="MsoNormal">
<p class="MsoNormal">in this way we can easily load onload functions in the div. we combine the whole code and looks like that:</p>
<pre name="code" class="php">

&lt;?php
include_once &#039;config.php&#039;;
?&gt;
&lt;script&gt;
var onload = [];
onload.push(function() {
//ONLOAD STUFFS HERE
msg_laod();
do_ajax();

});

function msg_laod()
{
document.getElementById(&#039;msg&#039;).setInnerHTML(&#039;test message content&#039;);

}

function do_ajax()
{
var ajax = new Ajax();
ajax.ondone = function(data) {
document.getElementById(&#039;req&#039;).setInnerFBML(data);
}
ajax.requireLogin = 1;
ajax.responseType = Ajax.FBML;
ajax.post(&#039;ajax callback url&#039;);
}

&lt;/script&gt;
&lt;div id=&quot;msg&quot; style=&quot;width:398px;height:298px;&quot;&gt;test message content&lt;/div&gt;
&lt;div id=&quot;ajax&quot; style=&quot;width: 398px; height: 298px;&quot;&gt; &lt;/div&gt;

&lt;script&gt;
//the very last thing on the page
setTimeout(function() {
for(var a = 0;a &lt; onload.length;a++) {onload[a]();}
}, 100);
&lt;/script&gt;
</pre>
<p><strong>reference</strong> :</p>
<p><a href="http://forum.developers.facebook.com/viewtopic.php?id=5117">http://forum.developers.facebook.com/viewtopic.php?id=5117</a><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/15/how-to-trigger-multiple-onload-functions-when-divs-are-loaded-by-fbjs/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>embedding google map in canvas</title>
		<link>http://fbcookbook.ofhas.in/2009/02/15/embedding-static-google-map-in-canvas/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/15/embedding-static-google-map-in-canvas/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 00:44:11 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[External]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[iFrame]]></category>
		<category><![CDATA[fb:iframe]]></category>
		<category><![CDATA[Google Map]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=264</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/15/embedding-static-google-map-in-canvas/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'embedding google map in canvas';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>




ever tried to embed static google map in your facebook application canvas? wait a bit, i think you are firing a question at me &#8220;whats the difference, its all the same, a static image, eh?&#8221; &#8211; nope! it wont work the way you think . whenever you try to embed a static google map image, [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/15/embedding-static-google-map-in-canvas/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'embedding google map in canvas';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>ever tried to embed static google map in your facebook application canvas? wait a bit, i think you are firing a question at me &#8220;whats the difference, its all the same, a static image, eh?&#8221; &#8211; nope! it wont work the way you think . whenever you try to embed a static google map image, google parse it as a &#8220;Bad Or Malformed&#8221; request and returns nothing! and in canvas url you can&#8217;t directly import any javascript but fbjs. so all we have to do is embed google map using a &lt;fb:iframe /> object</p>
<p>enough said, lets see it in action. first try to embed a google static map in regular way and see the result. </p>
<pre name="code" class="php">

&lt;php
include_once(&quot;config.php&quot;);
?&gt;
Here is the map of Dhaka &lt;br/&gt;
&lt;img src=&#039;http://maps.google.com/staticmap?center=23.70991,90.407&amp;amp;amp;zoom=14&amp;amp;amp;size=400x300&amp;amp;amp;key=&lt;api_key&gt;=23.7099,90.407,green&#039; /&gt; &lt;br/&gt;
Pretty cool, ya?
</pre>
<p>output is </p>
<pre name="code" class="html">

Here is the map of Dhaka
Pretty cool, ya?
</pre>
<p>you will be surprised that this code will render only the texts and no image in your application canvas, though the image url is fully valid. </p>
<p>now here is the revised version using &lt;fb:iframe /></p>
<pre name="code" class="php">

&lt;?php
include(&quot;config.php&quot;);
?&gt;
Here is the map of Dhaka &lt;br/&gt;
&lt;fb:iframe width=&#039;400&#039; height=&#039;300&#039; style=&#039;border:0&#039; frameborder=&#039;0&#039; src=&#039;http://sandbox.ofhas.in/fbtest/map.php?lat=23.7099&amp;amp;amp;lon=90.407&#039; &gt;&lt;/fb:iframe&gt;
&lt;br/&gt;
Pretty cool, eh?
</pre>
<p>we are using a map generator (map.php) using the latitude and longitude of a specific location, as the source of our iframe. so here is the source code of map.php</p>
<pre name="code" class="javascript">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
    &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;
  &lt;head&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
    &lt;title&gt;Google Maps JavaScript API Example: Map Markers&lt;/title&gt;
    &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=&lt;api_key&gt;&quot;
            type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById(&quot;map_canvas&quot;));
        map.setCenter(new GLatLng(&lt;?=$_GET[&#039;lat&#039;];?&gt;, &lt;?=$_GET[&#039;lon&#039;];?&gt;), 13);

          var point = new GLatLng(&lt;?=$_GET[&#039;lat&#039;];?&gt;, &lt;?=$_GET[&#039;lon&#039;];?&gt;);
          map.addOverlay(new GMarker(point));
      }
    }

    &lt;/script&gt;
  &lt;/head&gt;

  &lt;body onload=&quot;initialize()&quot; onunload=&quot;GUnload()&quot; style=&#039;margin:auto;padding:0px;&gt;
    &lt;div id=&quot;map_canvas&quot; style=&quot;width: 398px; height: 298px;margin:10 0;border:1px solid #ccc;&quot;&gt;&lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>this time output is pretty cool <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  have a look</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-18.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-18-300x264.png" alt="picture-18" title="picture-18" width="300" height="264" class="alignnone size-medium wp-image-266" /></a></p>
<p>so this is it! in our next article we are coming with the complete source code of a standalone twitter like application, developed using FBConnect to allow you to monitor your friend&#8217;s status and also to change yours. stay tuned <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/15/embedding-static-google-map-in-canvas/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>how to send notifications and emails</title>
		<link>http://fbcookbook.ofhas.in/2009/02/13/how-to-send-notifications-and-emails/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/13/how-to-send-notifications-and-emails/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 13:26:35 +0000</pubDate>
		<dc:creator>Mahmud Ahsan</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Notification]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[facebook email]]></category>
		<category><![CDATA[facebook notification]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=245</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/13/how-to-send-notifications-and-emails/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to send notifications and emails';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>




sending notifications and emails are very important features of a facebook app. now i&#8217;m going to show how you will send notifications and emails to users.
there are two types of notifications: user-to-user and application-to-user

a user-to-user notification is sent on behalf of one user to one or more other users
application-to-user notifications are sent on an application&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/13/how-to-send-notifications-and-emails/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to send notifications and emails';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
sending notifications and emails are very important features of a facebook app. now i&#8217;m going to show how you will send notifications and emails to users.</p>
<p>there are two types of notifications: user-to-user and application-to-user</p>
<ul>
<li>a user-to-user notification is sent on behalf of one user to one or more other users</li>
<li>application-to-user notifications are sent on an application&#8217;s behalf and do not require an active session.</li>
</ul>
<p><strong>case 1:</strong> suppose you have an application question/answer type. let user  &#8216;x&#8217; sent a question to user &#8216;y&#8217;. so how will you notify user &#8216;y&#8217; that he received a question. you can send a notification to user &#8216;y&#8217; from user &#8216;x&#8217; and also you could send an email to user &#8216;y&#8217; from user &#8216;x&#8217;.</p>
<p><strong>solution:</strong> for sending notification you could write this code</p>
<pre name="code" class="php">

/*------- sends a notification or request to a set of users. notifications are items sent by an application to a user&#039;s notifications page in response to some sort of user activity within an application ----------*/
// $facebook-&gt;api_client-&gt;notifications_send(ids, notificationmessage, notificationtype);

$facebook-&gt;api_client-&gt;notifications_send(&#039;654321890&#039;, &quot;you&#039;ve received a msg from &lt;fb:name uid=&#039;7464635353&#039; /&gt;&quot;, &#039;user_to_user&#039;);
</pre>
<p>this notification is sent from user to user, that&#8217;s why you&#8217;ve to mention notification type as &#8216;user_to_user&#8217;</p>
<p>another imortant thing is that, you could send same notifications to more than one users as a single api call. just specify the ids as a comman separated list like</p>
<pre name="code" class="php">

$facebook-&gt;api_client-&gt;notifications_send(&#039;654321890,656565654, 49393939&#039;, &quot;msg&quot;, &#039;user_to_user&#039;);
</pre>
<p><img class="alignnone size-full wp-image-248" title="notifications_by_ma1" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/notifications_by_ma1.png" alt="notifications_by_ma1" width="240" height="189" /></p>
<p><strong>case 2:</strong> let you also want to send an email to user &#8216;y&#8217; from user &#8216;x&#8217; in the situation of case 1.</p>
<p><strong>solution:</strong> you could only send emails to the users, who have both authorized your application and granted it the email extended permission. so how will you ask the user for accepting extended permission for email. here is the way. write the below code in your view page or layout:</p>
<pre name="code" class="php">

&lt;fb:prompt-permission perms=&quot;email&quot;&gt;Would you like to receive email from our application?&lt;/fb:prompt-permission&gt;
</pre>
<p>this will render this link in your view page:<br />
<img class="alignnone size-full wp-image-250" title="email_extended_permiss_ma1" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/email_extended_permiss_ma1.png" alt="email_extended_permiss_ma1" width="371" height="66" /></p>
<p>when user will click this link, a dialog box will open and show user a message  to accept receive emails permission. if user accept this permission, then this link will not shown to that user in future.</p>
<p>here is the api call that you have to use to send email:</p>
<pre name="code" class="php">

//$facebook-&gt;api_client-&gt;notifications_sendEmail(&#039;recipients&#039;, &#039;mail_subject&#039;, &quot;tex&quot;, &#039;fbml&#039;);
$facebook-&gt;api_client-&gt;notifications_sendEmail(&#039;73737373&#039;, &#039;you received a question&#039;, &quot;&quot;, &quot;hi user &lt;fb:name uid=&#039;47363633&#039; /&gt; has sent you a message&quot;);
</pre>
<p>remember the parameters:</p>
<ul>
<li><strong>recipients: </strong>a comma-separated list of recipient IDs. you can email up to 100 people at a time.</li>
<li><strong>subject:</strong> the subject of the email message. as of 10/28/2008, the subject will accept a limited set of fbml tags, including names, and tags related to internationalization.</li>
<li><strong>text:</strong> the plain text version of the email content. you must include a non-empty value for at least one of either the fbml or text parameters. the fbml input takes precedence, but if the given fbml value is invalid or cannot be rendered, then the text will be used instead. there is currently no character limit on the length of either the text or fbml body.</li>
<li><strong>fbml: </strong>the fbml version of the email. you must include a non-empty value for at least one of either the fbml or text parameters. the fbml parameter is a stripped-down set of fbml  that allows only html/fbml tags that result in text, links, linebreaks, as well as tags related to internationalization.</li>
</ul>
<p>references:</p>
<ul>
<li><a href="http://wiki.developers.facebook.com/index.php/Notifications.sendEmail">http://wiki.developers.facebook.com/index.php/Notifications.sendEmail</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Notifications.send">http://wiki.developers.facebook.com/index.php/Notifications.send</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Fb:prompt-permission">http://wiki.developers.facebook.com/index.php/Fb:prompt-permission</a></li>
</ul>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/13/how-to-send-notifications-and-emails/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>how to show facebook friends status</title>
		<link>http://fbcookbook.ofhas.in/2009/02/13/how-to-show-facebook-friends-status/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/13/how-to-show-facebook-friends-status/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 19:34:20 +0000</pubDate>
		<dc:creator>Junal Rahman</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[FQL]]></category>
		<category><![CDATA[Status]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=241</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/13/how-to-show-facebook-friends-status/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to show facebook friends status';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>




facebook status api is still in beta, in one of previous posts hasin showed how to set status of users with their permission. now, let&#8217;s see how we can get our facebook friend&#8217;s status, in next step i will  show a tricky way to get a random person&#8217;s status who is not your facebook [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/13/how-to-show-facebook-friends-status/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to show facebook friends status';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
facebook <a href="http://wiki.developers.facebook.com/index.php/Status.get" target="_blank">status api</a> is still in beta, in one of previous posts <a href="http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/" target="_blank">hasin showed how to set status</a> of users with their permission. now, let&#8217;s see how we can get our facebook friend&#8217;s status, in next step i will  show a tricky way to get a random person&#8217;s status who is not your facebook friend.</p>
<p>first let&#8217;s see how we can show our friends status. these following lines of code will return us an array</p>
<pre name="code" class="php">

include_once(&quot;config.php&quot;);
//i&#039;m using my own id
$user_status= $facebook-&gt;api_client-&gt;fql_query(&quot;SELECT status FROM user WHERE uid =579152077&quot;);
echo &quot;&lt;pre&gt;&quot;;
print_r($user_status);
echo &quot;&lt;/pre&gt;&quot;;
//this will return an array like following
Array
(
    [0] =&gt; Array
        (
            [status] =&gt; Array
                (
                    [message] =&gt; is testing facebook status api.
                    [time] =&gt; 1234464510
                    [status_id] =&gt; 53699066735
                )

        )

)
</pre>
<p>so we can get any of  our facebook friends&#8217; status like this. If no status messages are found, the method returns an empty <code>status_get_response</code> element. now, the thing is, we can check our friends status from &#8220;live feed&#8221; tab on our home page right? so  this status api could be interesting if we can show random friend&#8217;s status eh? unfortunately, this current beta API doesn&#8217;t support to get any random friends status but for the time being there is a possible way to get status of a person who is not our facebook friends BUT if he/she has at least 1 mutual friend. so let&#8217;s find a least possible way to get a random friend&#8217;s status who is NOT our friend on facebook but has a mutual friend. don&#8217;t worry, you don&#8217;t have to know his or her id <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  let&#8217;s have a look at following code.</p>
<pre name="code" class="php">

include_once(&quot;config.php&quot;);
//get id by the random person&#039;s full name
$user_details = $facebook-&gt;api_client-&gt;fql_query(&quot;SELECT uid FROM user WHERE name = &#039;your_random_friend_full_name&#039;&quot;);
//if this full name is unique and has a mutual friend with you, you can get his/her id like this...
$user_details[0][&#039;uid&#039;];
//now let&#039;s find out the status of that person
$status_array= $facebook-&gt;api_client-&gt;fql_query(&quot;SELECT status FROM user WHERE uid = {$user_details[0][&#039;uid&#039;]}&quot;);
//now, simply it will return an array with status message like before.
</pre>
<p>I know this is not the right way to get status. i strongly believe facebook should open this status access to random friends with email id or full name &#8211; only then we can expect lot&#8217;s of cool application on facebook based on this status api.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3649773907774827";
/* 468x15, created 9/26/09 */
google_ad_slot = "6695465500";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/13/how-to-show-facebook-friends-status/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>how to successfully keep record of which friend is accepting your invitation</title>
		<link>http://fbcookbook.ofhas.in/2009/02/13/how-to-successfully-keep-record-of-which-friend-is-accepting-your-invitation/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/13/how-to-successfully-keep-record-of-which-friend-is-accepting-your-invitation/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 18:21:35 +0000</pubDate>
		<dc:creator>Raquibul Islam</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Invitation]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[tracking invitation]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=197</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/13/how-to-successfully-keep-record-of-which-friend-is-accepting-your-invitation/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to successfully keep record of which friend is accepting your invitation';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
to keep record lets create a table named users .



CREATE TABLE `friends` (
`uid` INT NOT NULL ,
`rid` INT NOT NULL ,
) ;


then you have to add a small code snippet in the invitation code.we just need to add &#38;next=&#8217;.urlencode(&#8217;?rid=&#8217;.$user).
have a look in side the content there is a php line which will show the choose [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/13/how-to-successfully-keep-record-of-which-friend-is-accepting-your-invitation/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to successfully keep record of which friend is accepting your invitation';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>to keep record lets create a table named users .</p>
<p class="MsoNormal"><span class="syntaxpunctsyntaxpunctbracketcloseround">
<pre name="code" class="sql">

CREATE TABLE `friends` (
`uid` INT NOT NULL ,
`rid` INT NOT NULL ,
) ;
</pre>
<p></span></p>
<p>then you have to add a small code snippet in the invitation code.we just need to add &amp;next=&#8217;.urlencode(&#8217;?rid=&#8217;.$user).</p>
<p>have a look in side the content there is a php line which will show the choose with a url .<br />
just after adding the new code the url will look like</p>
<p class="MsoNormal"><span class="syntaxpunctsyntaxpunctbracketcloseround">
<pre name="code" class="php">

echo htmlentities(&#039;&lt;fb:req-choice url=&quot;http://www.facebook.com/add.php?api_key=&#039;.$appapikey.&#039;next=&#039;.urlencode(&#039;?rid=&#039;.$user).&#039;&quot; label=&quot;app name&quot; /&gt;&#039;);
</pre>
<p></span></p>
<p>now we have to change the setting of the application .and change the <strong>Post-Add Redirect URL</strong> like this</p>
<p style="text-align: center;">
<p><img class="size-full wp-image-112 alignnone" title="Facebook application setting" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-7.png" alt="Facebook application setting" width="459" height="311" /></p>
<p>this is the <strong>install.php</strong></p>
<p><span class="syntaxpunctsyntaxpunctbracketcloseround">
<pre name="code" class="php">

include ‘config.php’;

//$url is ur desired location where u want to user to be redirected after installation (ie : invite page) ;
$url = &quot;http://apps.facebook.com/appname/invite.php&quot;;

mysql_query(“insert into users value (‘$user’,$_GET[‘rid’]);”);

$facebook-&gt;redirect($url);
?&gt;
</pre>
<p></span></p>
<p>how dose it works ? first we are sending the current user id in invitation page. and as we set the <strong>Post-Add Redirect URL</strong> to a page when any user install the application from the invitation he/she will be redirect to the <strong>install.php</strong> page and the first user who invited him/her will be passed to <strong>install.php</strong> page using HTTP GET method .they store those 2 user id as u want .</p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/13/how-to-successfully-keep-record-of-which-friend-is-accepting-your-invitation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>tips for successful XFBML rendering</title>
		<link>http://fbcookbook.ofhas.in/2009/02/12/tips-for-successful-xfbml-rendering/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/12/tips-for-successful-xfbml-rendering/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 15:57:01 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[FB Connect]]></category>
		<category><![CDATA[iFrame]]></category>
		<category><![CDATA[xfbml]]></category>
		<category><![CDATA[Rendering]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=234</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/12/tips-for-successful-xfbml-rendering/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'tips for successful XFBML rendering';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
if you are creating a FBConnect application and suffering from unexpected result of XFBML renedeing in your application, here is a cool tip for you. always close yoour tag in &#60;tag&#62;&#60;/tag&#62; style and not like &#60;tag/&#62;. check out the following example for the differnece  &#8211;  


&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; xmlns:fb=&#34;http://www.facebook.com/2008/fbml&#34;&#62;
&#60;head&#62;&#60;/head&#62;
&#60;script src=&#34;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62;
&#60;body&#62;
&#60;div id=&#34;users&#34;&#62;&#60;/div&#62;
&#60;fb:login-button&#62;&#60;/fb:login-button&#62;
&#60;script type=&#34;text/javascript&#34;&#62;
 function renderXfbml(uid) [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/12/tips-for-successful-xfbml-rendering/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'tips for successful XFBML rendering';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>if you are creating a FBConnect application and suffering from unexpected result of XFBML renedeing in your application, here is a cool tip for you. always close yoour tag in &lt;tag&gt;&lt;/tag&gt; style and not like &lt;tag/&gt;. check out the following example for the differnece  &#8211; <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre name="code" class="php">

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;
&lt;head&gt;&lt;/head&gt;
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;body&gt;
&lt;div id=&quot;users&quot;&gt;&lt;/div&gt;
&lt;fb:login-button&gt;&lt;/fb:login-button&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 function renderXfbml(uid) {
 			document.getElementById(&quot;users&quot;).innerHTML = &quot;&lt;fb:name uid=&#039;loggedinuser&#039; useyou=&#039;false&#039; /&gt; has sent a gift to &lt;fb:name uid=&#039;1009983642&#039; /&gt;&quot;;
 			FB.XFBML.Host.parseDomTree();
 	 	}
 FB.init(&quot;5b8d7fcc4d851e29908620757be663d1&quot;, &quot;http://sandbox.ofhas.in/fbtest/xd_receiver.htm&quot;, {&quot;ifUserConnected&quot; : renderXfbml});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>the output looks like the following one, which is no way an expected one &#8211; but the XFBML used in the example above is totally valid. it must show something like <b>Hasin Hayder has sent a gift to Rajeeb Khan</b></p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-161.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-161.png" alt="picture-161" title="picture-161" width="171" height="79" class="alignnone size-full wp-image-235" /></a></p>
<p>Now check out the revised XFBML block in the following example. </p>
<pre name="code" class="php">

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;
&lt;head&gt;&lt;/head&gt;
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;body&gt;
&lt;div id=&quot;users&quot;&gt;&lt;/div&gt;
&lt;fb:login-button&gt;&lt;/fb:login-button&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 function renderXfbml(uid) {
 			document.getElementById(&quot;users&quot;).innerHTML = &quot;&lt;fb:name uid=&#039;loggedinuser&#039; useyou=&#039;false&#039;&gt;&lt;/fb:name&gt; has sent a gift to &lt;fb:name uid=&#039;1009983642&#039;&gt;&lt;/fb:name&gt;&quot;;
 			FB.XFBML.Host.parseDomTree();
 	 	}
 FB.init(&quot;5b8d7fcc4d851e29908620757be663d1&quot;, &quot;http://sandbox.ofhas.in/fbtest/xd_receiver.htm&quot;, {&quot;ifUserConnected&quot; : renderXfbml});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>and the output produced by the code above is perfect!</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-17.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-17-300x71.png" alt="picture-17" title="picture-17" width="300" height="71" class="alignnone size-medium wp-image-236" /></a></p>
<p>hope you will take care of this issue and prevent yourself from stumbling. happy FBConnecting</p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/12/tips-for-successful-xfbml-rendering/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>dealing with ajax  on FBConnect</title>
		<link>http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 11:21:29 +0000</pubDate>
		<dc:creator>Saidur Rahman</dc:creator>
				<category><![CDATA[FB Connect]]></category>
		<category><![CDATA[FBJS]]></category>
		<category><![CDATA[ajax]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=209</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'dealing with ajax  on FBConnect';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
  problem : 
need to store users information by ajax call while on connect . but face problems using fbjs ajax calls using on connect .some times face the problem to send ajax request  in the forum also get related type of problems . like:
http://forum.developers.facebook.com/viewtopic.php?id=28153
http://forum.developers.facebook.com/search.php?search_id=92171720
let’s see a quick solution by a common example.
solution:
here we [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'dealing with ajax  on FBConnect';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><span class="mceItemObject"   classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></span> <mce:style><!  st1\:*{behavior:url(#ieooui) } --> <!--[endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-language:AR-SA;} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]> <mce:style><!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--><strong>problem : </strong><br />
need to store users information by ajax call while on connect . but face problems using fbjs ajax calls using on connect .some times face the problem to send ajax request  in the forum also get related type of problems . like:</p>
<p><a href="http://forum.developers.facebook.com/viewtopic.php?id=28153">http://forum.developers.facebook.com/viewtopic.php?id=28153</a><br />
<a href="http://forum.developers.facebook.com/search.php?search_id=92171720">http://forum.developers.facebook.com/search.php?search_id=92171720</a></p>
<p>let’s see a quick solution by a common example.</p>
<p><strong>solution:</strong></p>
<p>here we look at the after connect get user profile picture and name by connect.</p>
<p>we create a script connect.php and include the  config  file .connect.php</p>
<pre name="code" class="php">

&lt;?php
/*
* include config file
*/
?&gt;

&lt;div id=&quot;user&quot;&gt; &lt;/div&gt;
&lt;fb:login-button onlogin=&quot;update_user_box();&quot;&gt;&lt;/fb:login-button&gt;
&lt;script type=&quot;text/javascript&quot;&gt;FB.init(&quot;key&quot;, &quot;xd_receiver.php&quot;); &lt;/script&gt;&lt;span style=&quot;display: block; padding-left: 6em;&quot;&gt;&lt;span&gt;
</pre>
<p>now it&#8217;s look like that:</p>
<p><img class="alignnone size-full wp-image-210" title="fb_conn_ajax" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/fb_conn_ajax.jpg" alt="fb_conn_ajax" /><br />
here in the connect button add onlogin function update_user_box().while click on connect then this function will call and update user by profile picture and name in the user id div.</p>
<p>in that update_user_box() function we will get the profile picture and name by calling ajax. So later on we can do anything by ajax.to call the ajax we will do it by jquery. Here I cannot do it by the fbjs  ajax method. For that reason I add jquery and other scripts.</p>
<pre name="code" class="php">

&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>now update update_user_box</p>
<pre name="code" class="php">

&lt;script type=&quot;text/javascript&quot;&gt;
function update_user_box()

{

Var url = “http://www.t...com.display.php”; // ajax url which is here display.php

$.ajax({
type: &quot;POST&quot;,
url:url,
data: &quot;save=yes&quot;,
success: function(msg){
var user_box = document.getElementById(&quot;user&quot;);
user_box.innerHTML =msg;

}
});
}
</pre>
<p>now create the display.php Which call by ajax.</p>
<p>In the display php also include config file which include facebook client library</p>
<p>here is code</p>
<pre name="code" class="php">
&lt;?php
define(MAIN_PATH, realpath(&#039;.&#039;));
include_once MAIN_PATH.&#039;/init.php&#039;;
$fb_uid = facebook_client()-&gt;get_loggedin_user();
echo &#039;&lt;span&gt; &lt;fb:profile-pic uid=&#039;.$fb_uid.&#039; facebook-logo=true&gt;&lt;/fb:profile-pic&gt; Welcome, &lt;fb:name uid=&#039;.$fb_uid.&#039; useyou=false&gt;&lt;/fb:name&gt;. You are signed in with your Facebook account.&lt;/span&gt;&#039;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;

?&gt;
&lt;span style=&quot;display: block; padding-left: 6em;&quot;&gt;&lt;span&gt;
</pre>
<p>this display.php returns the user profile picture and name. and it&#8217;s look like that.</p>
<p><img class="alignnone size-full wp-image-220" title="fb_conn_ajax3" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/fb_conn_ajax3.jpg" alt="fb_conn_ajax3" width="387" height="104" /></p>
<p>that&#8217;s it <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>displaying a &#8220;friend selector&#8221; in FBConnect application &#8211; a custom component for you</title>
		<link>http://fbcookbook.ofhas.in/2009/02/10/displaying-a-friend-selector-in-fbconnect-application-a-custom-component-for-you/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/10/displaying-a-friend-selector-in-fbconnect-application-a-custom-component-for-you/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 11:48:29 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[FB Connect]]></category>
		<category><![CDATA[FBJS]]></category>
		<category><![CDATA[FQL]]></category>
		<category><![CDATA[iFrame]]></category>
		<category><![CDATA[xfbml]]></category>
		<category><![CDATA[FBML]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=183</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/10/displaying-a-friend-selector-in-fbconnect-application-a-custom-component-for-you/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'displaying a &#8220;friend selector&#8221; in FBConnect application &#8211; a custom component for you';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
ok, i have learned my lesson while integrating  &#60;fb:multi-friend-selector [condensed] /&#62; and &#60;fb:multi-friend-input /&#62; in an iFrame app where i was rying to render it uwing &#60;fb:serverfbml&#62;. i was designing a page where users of your application can select an item, then some of their friends and finally submit the form to the handler [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/10/displaying-a-friend-selector-in-fbconnect-application-a-custom-component-for-you/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'displaying a &#8220;friend selector&#8221; in FBConnect application &#8211; a custom component for you';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>ok, i have learned my lesson while integrating  &lt;fb:multi-friend-selector [condensed] /&gt; and &lt;fb:multi-friend-input /&gt; in an iFrame app where i was rying to render it uwing &lt;fb:serverfbml&gt;. i was designing a page where users of your application can select an item, then some of their friends and finally submit the form to the handler script (might be javascript routine too!)</p>
<p>as &lt;fb:serverfbml /&gt; renders the &lt;fb:request-form /&gt; inside another iframe (thats right &#8211; iframe inside an iframe) so its quite tough job to pass external data to any of the DOM element inside those iframe. later, i tried to dynamically render the &lt;fb:serverfbml /&gt; with the help of AJAX and XFBML.parseDOMTree() but no luck. the surprising fact that everything out there was renedring properly but not the request form (when returned via ajax). so finally i did it with FQL and by building a custom friend selector component. so here it is</p>
<pre name="code" class="javascript">

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Custom Friend Selector&lt;/title&gt;
&lt;/head&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;body&gt;
&lt;fb:login-button&gt;&lt;/fb:login-button&gt;&lt;br/&gt;&lt;br/&gt;
Hello &lt;span id=&quot;me&quot; uid=&quot;503274632&quot; useyou=&#039;false&#039;&gt;&lt;/span&gt; And here is your friend list&lt;br/&gt;

&lt;div id=&quot;friends&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;script type=&quot;text/javascript&quot;&gt; 

function loadFriends(uid) {

    FB.XFBML.Host.autoParseDomTree = false;
    FB.XFBML.Host.addElement(new FB.XFBML.Name(document.getElementById(&quot;me&quot;)));

    FB_RequireFeatures([&quot;CanvasUtil&quot;], function(){  FB.CanvasClient.startTimerToSizeToContent(); });
    var api = FB.Facebook.apiClient;
    api.fql_query(&quot;SELECT uid, first_name, last_name FROM user WHERE  uid IN (SELECT uid2 FROM friend WHERE uid1 = &quot;+uid+&quot;) order by first_name&quot;, function(result, ex) {

        data = &quot;&lt;table&gt;&quot;;
        for (i=0;i&lt;result.length;i++)
        {
            data += &quot;&lt;tr&gt;&lt;td&gt;&lt;input type=&#039;checkbox&#039; value=&#039;&quot;+result[i].uid+&quot;&#039; name=&#039;friends[]&#039; id = &#039;friend&quot;+result[i].uid+&quot;&#039; /&gt;&lt;/td&gt;&lt;td&gt;&quot;+ result[i].first_name + &quot; &quot; + result[i].last_name+&quot;&lt;/td&gt;&lt;/tr&gt;&quot;;
        }
        data +=&quot;&lt;/table&gt;&quot;;
        $(&#039;#friends&#039;).css({&quot;overflow-y&quot;:&quot;scroll&quot;,&quot;height&quot;:&quot;200px&quot;,&quot;width&quot;:&quot;300px&quot;,&quot;border&quot;:&quot;1px solid #ccc&quot;});
        $(&#039;#friends&#039;).html( data);

    });
}

FB.init(&quot;api_key&quot;, &quot;xd_receiver.php&quot;,{&quot;ifUserConnected&quot;:loadFriends});

&lt;/script&gt;
</pre>
<p>and here is how it looks, </p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-151.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-151-300x266.png" alt="picture-151" title="picture-151" width="300" height="266" class="alignnone size-medium wp-image-191" /></a></p>
<p>you will find it useful in your FBConnect applications <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/10/displaying-a-friend-selector-in-fbconnect-application-a-custom-component-for-you/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>facebook reveals status api &#8211; how to use it?</title>
		<link>http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 17:07:35 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Status]]></category>
		<category><![CDATA[extended permission]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=166</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'facebook reveals status api &#8211; how to use it?';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
today facebook revealed their new api to update user&#8217;s status, and i am quite certain that it will play a vital role in the massive &#8220;status&#8221; market that is controlled by twitter. lets see how we can update status of any users of your application using this new API called &#8220;status_set()&#8221;. first thing is to [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'facebook reveals status api &#8211; how to use it?';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>today facebook revealed their new api to <a href="http://developers.facebook.com/news.php?blog=1&#038;story=193">update user&#8217;s status</a>, and i am quite certain that it will play a vital role in the massive &#8220;status&#8221; market that is controlled by twitter. lets see how we can update status of any users of your application using this new API called &#8220;status_set()&#8221;. first thing is to update your facebook client library <a href="http://svn.facebook.com/svnroot/platform/clients/packages/facebook-platform.tar.gz">from this link</a> to make thie api available to your application. and oh, one more thing to note which is very important infact. your users must allow extended permissions for &#8220;status_update&#8221; before you can do it. </p>
<p>here is the code. first it asks for user&#8217;s permission to update his/her status directly from this application. if user grants the permission &#8211; we will display a form to our user. then the rest is just hitting the submitting button with new status</p>
<pre name="code" class="php">

&lt;?php
include_once(&quot;config.php&quot;);
if (!$facebook-&gt;api_client-&gt;users_hasAppPermission(&quot;status_update&quot;)){
echo &#039;&lt;fb:prompt-permission perms=&quot;status_update&quot; next_fbjs=&quot;greet()&quot;&gt;Let us update your status from this application&lt;/fb:prompt-permission&gt;&#039;;
$visibility = &quot;none&quot;;
}
else
$visibility = &quot;block&quot;;

if(isset($_POST[&#039;status&#039;]))
{
    $facebook-&gt;api_client-&gt;users_setStatus($_POST[&#039;status&#039;]);
    echo &quot;&lt;p&gt;Your status has been updated&lt;/p&gt;&quot;;
}
?&gt;
&lt;div id=&quot;statusdiv&quot; style=&quot;display:&lt;?=$visibility;?&gt;;&quot;&gt;
    &lt;form method=&quot;POST&quot;&gt;
        Please update your status:&lt;br/&gt;
        &lt;input type=&quot;text&quot; name=&quot;status&quot; /&gt; &lt;br/&gt;
        &lt;input type=&quot;submit&quot; value=&quot;change status&quot; /&gt;
    &lt;/form&gt;
&lt;/div&gt;

&lt;script&gt;
function greet()
{
    var session = &quot;&lt;?=$facebook-&gt;api_client-&gt;session_key;?&gt;&quot;;
    document.getElementById(&quot;statusdiv&quot;).setStyle(&quot;display&quot;,&quot;block&quot;);
    new Dialog().showMessage(&quot;Info&quot;,&quot;Thank you for granting us this permission! Now you can update your facebook status directly from here.&quot;);
}

&lt;/script&gt;
</pre>
<p>here is the sequence</p>
<p><b>screenshot 1: default view, before granting permission </b><br />
<a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-81.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-81-300x39.png" alt="picture-81" title="picture-81" width="300" height="39" class="alignnone size-medium wp-image-172" /></a></p>
<p><b>screenshot 2: permission dialogue, asking for the authorization </b><br />
<a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-91.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-91-300x106.png" alt="picture-91" title="picture-91" width="300" height="106" class="alignnone size-medium wp-image-173" /></a></p>
<p><b>screenshot 3: status update form </b><br />
<a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-101.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-101-300x100.png" alt="picture-101" title="picture-101" width="300" height="100" class="alignnone size-medium wp-image-174" /></a></p>
<p><b>screenshot 4: confirmation </b><br />
<a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-121.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-121-299x93.png" alt="picture-121" title="picture-121" width="299" height="93" class="alignnone size-medium wp-image-179" /></a></p>
<p>so this is it! pretty easy, eh?</p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
		<item>
		<title>friends selection custom component</title>
		<link>http://fbcookbook.ofhas.in/2009/02/06/friends-selection-custom-component/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/06/friends-selection-custom-component/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 10:10:41 +0000</pubDate>
		<dc:creator>Mahmud Ahsan</dc:creator>
				<category><![CDATA[FBML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[facebook widget]]></category>
		<category><![CDATA[friends selection custom component]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=156</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/06/friends-selection-custom-component/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'friends selection custom component';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
for 1 of my facebook application, i was  needed a custom friends selector. the purpose was, i&#8217;ve a page from where i&#8217;ve to select multiple friends and then i&#8217;ll submit those selected friend ids using ajax call without refreshing the page.
then i searched the documentation of fbml. in facebook component, there are 2 types of [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/06/friends-selection-custom-component/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'friends selection custom component';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>for 1 of my facebook application, i was  needed a custom friends selector. the purpose was, i&#8217;ve a page from where i&#8217;ve to select multiple friends and then i&#8217;ll submit those selected friend ids using ajax call without refreshing the page.</p>
<p>then i searched the documentation of fbml. in facebook component, there are 2 types of friends selector</p>
<ol>
<li><a href="http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector" target="_blank">http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector_(condensed)" target="_blank">http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector_(condensed)</a></li>
</ol>
<p><a href="http://mahmudahsan.files.wordpress.com/2008/12/face-1.png"><img class="aligncenter size-medium wp-image-298" title="face-1" src="http://mahmudahsan.files.wordpress.com/2008/12/face-1.png?w=300" alt="face-1" width="300" height="181" /></a><a href="http://mahmudahsan.files.wordpress.com/2008/12/face-2.png"><img class="aligncenter size-full wp-image-299" title="face-2" src="http://mahmudahsan.files.wordpress.com/2008/12/face-2.png" alt="face-2" width="234" height="157" /></a>but both of these are totally controlled by facebook and these components are used to send invitation or request to friends. i need a component like figure 2. the fbml code for the second component is below:</p>
<pre name="code" class="php">

&lt;fb:request-form method=”post” action=”http://yourdomain.com/submit.php” content=”Select Friends” type=”gifts” invite=”true”&gt;
&lt;div class=”clearfix” style=”padding-bottom: 10px;”&gt;
&lt;fb:multi-friend-selector condensed=”true” selected_rows=”0? style=”width: 220px;” /&gt;
&lt;/div&gt;
&lt;fb:request-form-submit /&gt;
&lt;/fb:request-form&gt;
</pre>
<p>but I was needed a component that would be fully controlled by me. so,  I developed a friends selection component and I&#8217;m sharing it. <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-156"></span></p>
<p>here is the outlook of my component:</p>
<p><a href="http://mahmudahsan.files.wordpress.com/2008/12/custom-friends-selection-component.png"><img class="aligncenter size-full wp-image-302" title="custom-friends-selection-component" src="http://mahmudahsan.wordpress.com/files/2008/12/custom-friends-selection-component.png" alt="custom-friends-selection-component" width="281" height="248" /></a></p>
<p style="text-align:center;font-size:16px;font-family:arial;"><a href="http://ftechdb.com/mahmudahsan.wordpress.com/custom-friends-selector2.txt" target="_blank">download custom friends selector for facebook application</a></p>
<p style="text-align:left;">there are 3 parts in this code:</p>
<ol>
<li>first part is css</li>
<li>second part is javascript</li>
<li>third part is html + php</li>
</ol>
<p>so changed the file extension to .php</p>
<p>Here is the first part:</p>
<pre name="code" class="css">

&lt;style&gt;

div.scroll {
height: 160px;
width: 200px;
overflow: auto;
border: 1px solid #666;
padding: 8px;
}

#listwords{
border: 1px solid #BDBABD;
margin-top: 5px;
margin-left: 10px;
}

#listwords ul{
list-style: none;
margin-top: -3px;
cursor: pointer;
}

#listwords span{
color: olive;
text-decoration: none;
}

.itemselect{
background-color: #e2dfaf;
color: #650202;
}

.itemmouseover{
background-color: #FFEEBB;
color: BLACK;
}

.itemnormal{
color: BLACK;
font-family: arial;
font-size: 12px;
}
</pre>
<p>this is the css code for the outlook of my component. here in the top you&#8217;ll see a bold part. this is a very important code that creates scroll bar when list is overflow than it&#8217;s height.</p>
<p>now the second part and 3rd part:<br />
<code>
<pre name="code" class="javascript">

&lt;script type=”text/javascript”&gt;
//javascript part
/*————————- Friends selection —————–*/
var friendsSelectedIds =   ”; //this is string
//send this variable to php
&lt;/code&gt;&lt;/code&gt;

function toggleSelect(id){
var liBox   =   document.getElementById(’li’ + id);
var chkBox  =   document.getElementById(’chk’ + id);

liBox.toggleClassName(’itemselect’);
if (chkBox.getChecked()){
friendsSelectedIds  =   friendsSelectedIds.replace(id + ‘,’, ”);
chkBox.setChecked(false);
}
else{
chkBox.setChecked(true);
friendsSelectedIds += id + ‘,’;
}

return false;
}
/*============== END ====================*/

function sendFriendIds(){
if (friendsSelectedIds.length == 0){
new Dialog().showMessage(’Select friends’, ‘Please select friends!’);
return false;
}

//submit form using ajax call
var ajax                = new Ajax();
ajax.responseType       = Ajax.FBML;

ajax.ondone        = function(data){
//task u will do
}

ajax.onerror = function(){
new Dialog(Dialog.DIALOG_POP).showMessage(’Error’, ‘Loading error! Please try again!’, button_confirm = ‘Okay’);
}

var queryParams = {”ids” : friendsSelectedIds};
ajax.post(’http://yourdomain.com/submit.php’ , queryParams);

}
&lt;/script&gt;
</pre>
<pre name="code" class="php">

&lt;!– html Part –&gt;
&lt;form name=’ffriends’ method=”POST” action=”&quot; onsubmit=”return false”&gt;
&lt;div class=”scroll” id=”listwords”&gt;
&lt;?php $i=0; ?&gt;
&lt;ul style=’margin-left: -44px’&gt;
&lt;?php foreach($friends as $item){ ?&gt;
&lt;li id=”li&lt;?=$item[&#039;uid&#039;]?&gt;” class=’itemnormal’ onclick=”toggleSelect(&lt;?=$item[&#039;uid&#039;]?&gt;)”&gt;
&lt;input id=”chk&lt;?=$item[&#039;uid&#039;]?&gt;” type=”checkbox” /&gt; &lt;fb:name uid=”&lt;?=$item[&#039;uid&#039;]?&gt;” linked=”false” /&gt;
&lt;/li&gt;
&lt;?php } ?&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;input style=”margin-left: 10px;” class=”inputsubmit” type=”Submit” value=”Send Question” onclick=”sendFriendIds()” /&gt;
&lt;/form&gt;
</pre>
<p><span style="color:#800000;"><span style="color:#000000;">it's best that you download the code and read my description. in html part, you will see a foreach loop where friends is an array of the friends you have. i retrieve the friends using fql and assigned the result in <strong>$friends variable</strong>.  when a friend is selected, it's id is saved in </span></span><span style="color:#003366;">friendsSelectedIds variable <span style="color:#000000;">in javascript. (like </span></span><span style="color:#003366;">friendsSelectedIds=12393939,45454545, <span style="color:#000000;">)</span></span><span style="color:#800000;"> <span style="color:#000000;">a comma is added after id. </span></span></p>
<p><span style="color:#800000;"><span style="color:#000000;">when a friend is unselected its id and comma is removed from the variable. this variable is a string variable. after selecting one or more friends when user press the submit button </span></span><span style="color:#003366;"><strong>sendFriendIds() <span style="color:#000000;">method</span></strong></span><span style="color:#800000;"> <span style="color:#000000;">is called. in this method you've to redefine the ajax functionalities for your work. </span></span><span style="color:#800000;"><span style="color:#000000;">if no friend is selected a message is shown to the user.</span></span><span style="color:#800000;"><span style="color:#000000;"> remember </span></span><span style="color:#003366;"><strong>var queryParams = {"ids" : friendsSelectedIds}; <span style="color:#000000;">ids </span></strong><span style="color:#000000;">is the selected ids of friends and this will be catched from server side script. and <strong>ids </strong>containted comma separated id of friends. i think this is a very small lines of code and easily understandable for facebook application developer.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/06/friends-selection-custom-component/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
