<?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 &#187; facebook</title>
	<atom:link href="http://fbcookbook.ofhas.in/tag/facebook/feed/" rel="self" type="application/rss+xml" />
	<link>http://fbcookbook.ofhas.in</link>
	<description>thousands of app development recipes</description>
	<lastBuildDate>Sun, 21 Mar 2010 10:38:11 +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 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>how to resize facebook popup dialog box</title>
		<link>http://fbcookbook.ofhas.in/2009/02/06/how-to-resize-facebook-popup-dialog-box/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/06/how-to-resize-facebook-popup-dialog-box/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 07:09:32 +0000</pubDate>
		<dc:creator>Junal Rahman</dc:creator>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[FBJS]]></category>
		<category><![CDATA[Feed]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[Hack]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=121</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/how-to-resize-facebook-popup-dialog-box/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to resize facebook popup dialog box';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
while developing facebook applications, sometimes we don&#8217;t like to use the default facebook popup dialog box, we want to resize/modify to show it on our own way. but how can we do it? we don&#8217;t have the css class on our hand right. but don&#8217;t worry, we have this simple trick to make it on [...]]]></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/how-to-resize-facebook-popup-dialog-box/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to resize facebook popup dialog box';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>while developing facebook applications, sometimes we don&#8217;t like to use the default facebook popup dialog box, we want to resize/modify to show it on our own way. but how can we do it? we don&#8217;t have the css class on our hand right. but don&#8217;t worry, we have this simple trick to make it on our own way.</p>
<p>let&#8217;s see how we can do it&#8230;.</p>
<p>first let&#8217;s see how a default popup box looks like. let&#8217;s print something pretty simple and set a button that will call the javascript function which will create the default popup dialog box. following code will do it for us..</p>
<pre name="code" class="php">
&lt;?php
include_once(&quot;config.php&quot;);
?&gt;
&lt;input type=&quot;button&quot; value=&quot;click me&quot; onclick=&quot; return showMe()&quot;&gt;
&lt;script language=&quot;javascript&quot;&gt;
function showMe()
{
   new Dialog().showMessage(&#039;Hi There&#039;, &#039; Hi, i\&#039;m a default pop-up, but shh you can play with me!&#039; );
}
&lt;/script&gt;
</pre>
<p>and this will generate a popup like the following screen shot.</p>
<div id="attachment_135" class="wp-caption aligncenter" style="width: 310px"><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/default1.png"><img class="size-medium wp-image-135" title="Default Dialog Box" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/default1-300x79.png" alt="Default Dialog Box" width="300" height="79" /></a><p class="wp-caption-text">Default Dialog Box</p></div>
<p>now, we want to change this default dialog box right. ok, this default dialog box uses some css classes which can be found using firefox add on firebug. one of them is called &#8220;dialog_body&#8221; which contains the body of the dialog box. Idea is to overwrite the css class to make it our own <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  let&#8217;s change the &#8220;dialog_body&#8221; class in the following way&#8230;</p>
<pre name="code" class="css">

&lt;style&gt;
.dialog_body{
   background-color:#CCCCCC !important;
   font-weight:bold !important;
   font-size:16px;
   text-align:center !important;
   padding-left:0px !important;
   padding-top:10px!important;
   padding-bottom:10px!important;
}
&lt;/style&gt;
</pre>
<p>just set the &#8220;!important&#8221; to get the priority over the existing properties. now let&#8217;s see how out new dialog box looks like ..</p>
<div id="attachment_137" class="wp-caption aligncenter" style="width: 310px"><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/bg1.png"><img class="size-medium wp-image-137" title="Changed Dialog Box" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/bg1-300x95.png" alt="Changed Dialog Box" width="300" height="95" /></a><p class="wp-caption-text">Changed Dialog Box</p></div>
<p style="text-align: center;">
<p>cool eh?<br />
now, how about make this popup dialog box wider than the default size? well, we have that trick too!<br />
this css class called &#8220;<em>pop_dialog_table</em>&#8220;, which holds the whole dialog box&#8217;s div. so increasing it&#8217;s width will also increase the size of the dialog box. so let&#8217;s do it!</p>
<pre name="code" class="css">

&lt;style&gt;
.pop_dialog_table {
   width: 650px !important;
}
&lt;/style&gt;
</pre>
<p>how this will look like then? have a look at the following screen shot</p>
<div id="attachment_151" class="wp-caption aligncenter" style="width: 310px"><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/long3.jpeg"><img class="size-medium wp-image-151" title="Wider Dialog Box" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/long3-300x61.jpg" alt="Wider Dialog Box" width="300" height="61" /></a><p class="wp-caption-text">Wider Dialog Box</p></div>
<p>simple eh? hope it helps to play with this popup dialog box on your own way!</p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/06/how-to-resize-facebook-popup-dialog-box/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>how to keep track of users of your application, and how to remove them properly when they remove it</title>
		<link>http://fbcookbook.ofhas.in/2009/02/05/how-to-keep-track-of-users-of-your-application-and-how-to-remove-them-properly-when-they-remove-it/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/05/how-to-keep-track-of-users-of-your-application-and-how-to-remove-them-properly-when-they-remove-it/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 14:44:06 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[uninstall]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=108</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/05/how-to-keep-track-of-users-of-your-application-and-how-to-remove-them-properly-when-they-remove-it/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to keep track of users of your application, and how to remove them properly when they remove it';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
there are two things we are going to discuss in this article. both of these are very important issues for successful marketing of your app, to generate precise traffic report. and if you want to sell your app or generate revenue, traffic report is very important. so we are going to show you how 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/05/how-to-keep-track-of-users-of-your-application-and-how-to-remove-them-properly-when-they-remove-it/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to keep track of users of your application, and how to remove them properly when they remove it';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>there are two things we are going to discuss in this article. both of these are very important issues for successful marketing of your app, to generate precise traffic report. and if you want to sell your app or generate revenue, traffic report is very important. so we are going to show you how to maintain a precise list of your active users and how to precisely remove them when they remove your app. </p>
<p><b>keeping track of your users</b><br />
this one is fairly easy. but beside storing their user id you should keep track of their session ids. why? for extended permissions and for viral marketing. lets create a mysql table for storing these data, along with the active/inactive</p>
<pre name="code" class="sql">

+------------+---------------------+------+-----+---------+-------+
| Field      | Type                | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| uid        | bigint(20) unsigned | NO   | PRI |         |       |
| sessionkey | varchar(128)        | YES  |     | NULL    |       |
| active     | char(1)             | YES  | MUL | 1       |       |
+------------+---------------------+------+-----+---------+-------+
</pre>
<p>here is the SQL</p>
<pre name="code" class="sql">

CREATE TABLE `users` (
  `uid` bigint(20) unsigned NOT NULL,
  `sessionkey` varchar(128) default NULL,
  `active` char(1) default &#039;1&#039;,
  PRIMARY KEY  (`uid`),
  KEY `activity` (`active`)
)
</pre>
<p>now can you remember that there is a field named &#8220;Post authorize redirect url&#8221; in the &#8220;Authentication&#8221; tab of your application settings page? set the data in that field before proceeding further. have a look at the following screenshot. you can see it&#8217;s enlarged view by clicking on it</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-7.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-7-300x203.png" alt="picture-7" title="picture-7" width="300" height="203" class="alignnone size-medium wp-image-112" /></a></p>
<p>now lets see how to store the user ids and their corresponding session key. in the following code block there are two functions for storing user ids in your database and for updating their session key. </p>
<pre name="code" class="php">

&lt;?php
/**
 * insert a new user and corresponding session key in the users table
 *
 * @param int $uid user id
 * @param string $sk session key
 * @param resource $db mysql connection resource
 * @return bool
 */
function insertUser($uid,$sk,$db)
{
    $data= mysql_query(&quot;select uid from users where uid=&#039;{$uid}&#039;&quot;,$db);
    if(mysql_num_rows($data)==0)
    {
        $sql = &quot;INSERT INTO users (uid,sessionkey, active) VALUES(&#039;{$uid}&#039;,&#039;{$sk}&#039;,&#039;1&#039;)&quot;;
        mysql_query($sql,$db);
        return true;
    }
    return false;
}

/**
 * update an user&#039;s corresponding session key in users table
 *
 * @param int $uid user id
 * @param string $sk session key
 * @param resource $db mysql connection resource
 * @return bool
 */
function updateSessionKey($uid,$sk,$db)
{
   return mysql_query(&quot;update users set sk = &#039;{$sk}&#039; where uid=&#039;{$uid}&quot;,$db);
}

?&gt;
</pre>
<p>now in your <b>install.php</b> all you have to do is place the following code.</p>
<pre name="code" class="php">

include_once(&quot;config.php&quot;);
$sk = $facebook-&gt;api_client-&gt;session_key;

$db = mysql_connect(&#039;host&#039;,&#039;user&#039;,&#039;db&#039;);
mysql_select_db(&quot;db&quot;,$db);

insertUser($uid,$sk, $db);
echo &quot;&lt;fb:redirect url=&#039;YourApplicationUrl&#039; /&gt;&quot;;
</pre>
<p>thats it. now you can periodically update your user&#8217;s session key to stay uptodate using updateSessionKey() function. </p>
<p><b>how to remove your user</b><br />
remember in the previous screenshot there was a field named &#8220;Post-Remove Callback URL&#8221; in the application setup page? when any of your application users remove this application from their account, facebook sends some information to this callback url so that you, the application developer, can successfully take necessary steps to remove this user from your database or set the inactive flag &#8220;ON&#8221;. lets see how to do this. here is the code of &#8220;remove.php&#8221;</p>
<pre name="code" class="php">

&lt;?php
include_once(&quot;config.php&quot;);
$facebook = new Facebook($apikey, $secret);
$user = $facebook-&gt;get_loggedin_user();
if ($user != NULL &amp;amp;amp;&amp;amp;amp; $facebook-&gt;fb_params[&#039;uninstall&#039;] == 1)
{
    makeUserInactive($uid,$db); //$db is your mysql link indentifier
}

/**
 * set an user as inactive, indicating that user has removed your application
 *
 * @param int $uid user id
 * @param resource $db mysql connection resource
 * @return bool
 */
function makeUserInactive($uid,$db)
{
    return mysql_query(&quot;update users set active = &#039;0&#039; where uid=&#039;{$uid}&quot;,$db);
}
?&gt;
</pre>
<p>thats it! for reference you can check out <a target='_blank' href="http://wiki.developers.facebook.com/index.php/Post-Remove_URL">facebook wiki entry</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/05/how-to-keep-track-of-users-of-your-application-and-how-to-remove-them-properly-when-they-remove-it/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>fbml rendering in iframe application</title>
		<link>http://fbcookbook.ofhas.in/2009/02/03/fbml-rendering-in-iframe-application/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/03/fbml-rendering-in-iframe-application/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 16:26:23 +0000</pubDate>
		<dc:creator>Mahmud Ahsan</dc:creator>
				<category><![CDATA[FBML]]></category>
		<category><![CDATA[iFrame]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fbml in iframe]]></category>
		<category><![CDATA[xfbml]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=57</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/03/fbml-rendering-in-iframe-application/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'fbml rendering in iframe application';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
before proceeding the main topic, at first i want to describe how to develop  iframe based facebook application. i assume that, the reader have minimum knowledge of how to develop canvas based facebook application. if you never develop any facebook application please visit: http://wiki.developers.facebook.com/index.php/creating_your_first_application
steps of developing iframe based facebook application:
1. when you setup a [...]]]></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/03/fbml-rendering-in-iframe-application/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'fbml rendering in iframe application';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>before proceeding the main topic, at first i want to describe how to develop  iframe based facebook application. i assume that, the reader have minimum knowledge of how to develop canvas based facebook application. if you never develop any facebook application please visit:<a href="http://wiki.developers.facebook.com/index.php/creating_your_first_application" target="_blank"> http://wiki.developers.facebook.com/index.php/creating_your_first_application</a></p>
<p>steps of developing iframe based facebook application:</p>
<p>1. when you setup a new application in facebook, choose  “use iframe” for canvas page url.<br />
2. now set the authentication code, at your bootstrap file:</p>
<pre name="code" class="php">

&lt;?php
include “facebook.php”;
$facebook = new facebook(’api_key’, ’secret_key’);
$user = $facebook-&gt;require_login();

//catch the exception that gets thrown if the cookie has an invalid session_key in it
try {
if (!$facebook-&gt;api_client-&gt;users_isappadded()) {
$facebook-&gt;redirect($facebook-&gt;get_add_url());
}
}
catch (exception $ex) { //this will clear cookies for your application and redirect them to a login prompt
$facebook-&gt;set_user(null, null);
$facebook-&gt;redirect(callback_url);
}
?&gt;
</pre>
<p>3. and don’t forget to place the necessary facebook php library. <a href="http://wiki.developers.facebook.com/index.php/php">http://wiki.developers.facebook.com/index.php/php</a></p>
<p>now i’m describing the main topic, that is how to render xfbml or fbml in your iframe based application.</p>
<p>1. first create a file called xd_receiver.htm<br />
2. place xd_receiver.htm in the root directory. suppose your application base directory is: <a href="http://myapp.com/iframeapp">http://myapp.com/iframeapp</a> . then place <strong>xd_receiver.htm</strong> in <strong>iframeapp </strong>folder.  now add the following html code to xd_receiver.htm .</p>
<pre name="code" class="html">

&lt;!doctype html public “-//w3c//dtd xhtml 1.0 strict//en” “http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd”&gt;
&lt;html xmlns=”http://www.w3.org/1999/xhtml” &gt;
&lt;head&gt;
&lt;title&gt;cross-domain receiver page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script src=”http://static.ak.facebook.com/js/api_lib/v0.4/xdcommreceiver.debug.js” type=”text/javascript”&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>now in your view file, or may be layout file, place this code. here i’m showing the layout files format for iframe application.</p>
<pre name="code" class="html">

&lt;!doctype html public “-//w3c//dtd xhtml 1.0 strict//en” “http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd”&gt;
&lt;html xmlns=”http://www.w3.org/1999/xhtml” xmlns:fb=”http://www.facebook.com/2008/fbml”&gt;

&lt;head&gt;
&lt;script src=”http://static.ak.facebook.com/js/api_lib/v0.4/featureloader.js.php” type=”text/javascript”&gt;&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;!– here is the fbml code in iframe application –&gt;

&lt;fb:serverfbml&gt;
&lt;script type=”text/fbml”&gt;
&lt;fb:fbml&gt;

&lt;fb:request-form action=”&lt;url for post invite action, see wiki page for fb:request-form for   details&gt;” method=”post” invite=”true” type=”xfbml” content=”this is a test invitation from xfbml test app &lt;fb:req-choice url=’see wiki page for fb:req-choice for details’ label=’ignore the connect test app!’ /&gt;  ” &gt;  &lt;fb:multi-friend-selector showborder=”false” actiontext=”invite your friends to use connect.”&gt;  &lt;/fb:request-form&gt;
&lt;/fb:fbml&gt;
&lt;/script&gt;
&lt;/fb:serverfbml&gt;
</pre>
<p><strong>&lt;!– here is the xfbml code –&gt;</strong></p>
<pre name="code" class="html">

this is &lt;fb:name uid=”&lt;?=$this-&gt;userid?&gt;” useyou=’false’&gt; &lt;/fb:name&gt;
my photo &lt;fb:profile-pic uid=”&lt;?=$this-&gt;userid?&gt;” &gt; &lt;/fb:profice-pic&gt;

&lt;!– remember all xfbml tags should be placed before below javascript code –&gt;

&lt;script type=”text/javascript”&gt;
fb_requirefeatures([&quot;xfbml&quot;], function(){
fb.facebook.init(”place here the api key of your application“, “xd_receiver.htm”);
});
&lt;/script&gt;

&lt;/body&gt;

&lt;/html&gt;
</pre>
<p>** <strong>remember xfbml is nothing but a subset of fbml that are supported for iframe application.</strong></p>
<p><strong>&lt;fb:serverfbml&gt;</strong> : this tag is used to renders the fbml on a facebook server inside an iframe. details of this tag is here: <a href="http://wiki.developers.facebook.com/index.php/fb:serverfbml">http://wiki.developers.facebook.com/index.php/fb:serverfbml</a></p>
<p>references:</p>
<p>1. <a href="http://wiki.developers.facebook.com/index.php/xfbml">http://wiki.developers.facebook.com/index.php/xfbml</a><br />
2. <a href="http://wiki.developers.facebook.com/index.php/cross-domain_communication_channel">http://wiki.developers.facebook.com/index.php/cross-domain_communication_channel</a><br />
3. <a href="http://wiki.developers.facebook.com/index.php/php">http://wiki.developers.facebook.com/index.php/php</a><br />
4. <a href="http://wiki.developers.facebook.com/index.php/creating_your_first_application">http://wiki.developers.facebook.com/index.php/creating_your_first_application</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/03/fbml-rendering-in-iframe-application/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>how to successfully update all of your user&#8217;s profile offline, at once! &#8211; part 1</title>
		<link>http://fbcookbook.ofhas.in/2009/02/03/how-to-successfully-update-all-of-your-users-profile-at-once-part-1/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/03/how-to-successfully-update-all-of-your-users-profile-at-once-part-1/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 15:05:43 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Profile]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[offline]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=47</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/03/how-to-successfully-update-all-of-your-users-profile-at-once-part-1/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to successfully update all of your user&#8217;s profile offline, at once! &#8211; part 1';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
sounds crazy right? but actually you can make a great use of this feature in your facebook application. lets think that your application is kind of a todo-list or birthday reminder. now your users will create tasks or added friend to be notified when their birthdays arrive, or when the eta of a task is [...]]]></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/03/how-to-successfully-update-all-of-your-users-profile-at-once-part-1/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'how to successfully update all of your user&#8217;s profile offline, at once! &#8211; part 1';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>sounds crazy right? but actually you can make a great use of this feature in your facebook application. lets think that your application is kind of a todo-list or birthday reminder. now your users will create tasks or added friend to be notified when their birthdays arrive, or when the eta of a task is in 24 hours. in these cases you may have to update those user&#8217;s profile in background so that when they visit their profile page &#8211; they will see the latest information, and that will be very useful for them. </p>
<p>there are two ways to accomplish this task</p>
<p>1. by calling setFBML offline, using any of user&#8217;s session key.<br />
2. by using &lt;fb:ref /> with an url handler, which is a smart way indeed. </p>
<p>in this article i am going to focus on first technique. next article will focus on 2nd one. </p>
<p><b>updating using profile_setFBML()</b><br />
to use this api offline, you first need a session key. the following code will print the session key for you. </p>
<pre name="code" class="php">

&lt;?php
echo $facebook-&gt;api_client-&gt;session_key;
?&gt;
</pre>
<p>this code will output something like &#8220;<em>6de106fa7e2de0820b091f12-503274632</em>&#8221; which is my session key for this application. </p>
<p>now you can update all of your user&#8217;s profile using the following code. please note that i have used batch api for the sake of performance. </p>
<pre name="code" class="php">

&lt;?php
require_once &#039;client/facebook.php&#039;;

$appapikey = &#039;ff0b3d87fc42915533e15dc238f2d447&#039;;
$appsecret = &#039;app_secret_key&#039;;
$sessionkey = &quot;6de106fa7e2de0820b091f12-503274632&quot;;
$facebook = new Facebook($appapikey, $appsecret);

$uid1 = 657561905;
$uid2 = 503274632;

$facebook-&gt;api_client-&gt;user = $uid2;
$facebook-&gt;api_client-&gt;session_key = $sessionkey;

$facebook-&gt;api_client-&gt;begin_batch();

$facebook-&gt;api_client-&gt;profile_setFBML(NULL, $uid1, &quot;Offline profile &lt;fb:name uid=&#039;{$uid1}&#039; useyou=&#039;false&#039; /&gt;&quot;, NULL, &#039;mobile_profile&#039;, &#039;profile_main&#039;);
$facebook-&gt;api_client-&gt;profile_setFBML(NULL, $uid2, &quot;Offline profile &lt;fb:name uid=&#039;{$uid2}&#039; useyou=&#039;false&#039; /&gt;&quot;, NULL, &#039;mobile_profile&#039;, &#039;profile_main&#039;);

$facebook-&gt;api_client-&gt;end_batch();
?&gt;
</pre>
<p>if you need to update thousands of your user&#8217;s profile at a time, using the batch api is a must or you will suffer from timeout. now you can execute this script by either command line &#8220;php &lt;script_file>.php&#8221; or by accessing it via browser <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>pretty neat, eh?</p>
<p>stay tuned for next part of this article where we will tell you how to update profile data offline using &lt;fb:ref /> with an url handler <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/03/how-to-successfully-update-all-of-your-users-profile-at-once-part-1/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
