<?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; Hasin Hayder</title>
	<atom:link href="http://fbcookbook.ofhas.in/author/hasin/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>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>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>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>10</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>65</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>updating profile box using &lt;fb:ref /&gt;</title>
		<link>http://fbcookbook.ofhas.in/2009/02/04/updating-profile-box-using-fbref/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/04/updating-profile-box-using-fbref/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 13:10:58 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Profile]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=95</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/04/updating-profile-box-using-fbref/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'updating profile box using &lt;fb:ref />';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
&#60;fb:ref is a new  fbml tag used to store data and later re-use it. there are two types of ref handler, one is static and another is url based. lets have a look at their structure
1. string handle which just stores FBML and later output the content &#8211; like


&#60;fb:ref handle=&#34;application_specific_unique_handle&#34; /&#62;

or
2. url based, which [...]]]></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/04/updating-profile-box-using-fbref/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'updating profile box using &lt;fb:ref />';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>&lt;fb:ref is a new  fbml tag used to store data and later re-use it. there are two types of ref handler, one is static and another is url based. lets have a look at their structure</p>
<p>1. string handle which just stores FBML and later output the content &#8211; like</p>
<pre name="code" class="html">

&lt;fb:ref handle=&quot;application_specific_unique_handle&quot; /&gt;
</pre>
<p>or</p>
<p>2. url based, which must serve valid FBML</p>
<pre name="code" class="html">

&lt;fb:ref url=&quot;some_url&quot; /&gt;
</pre>
<p>you can create &lt;fb:ref /&gt; by using fbml_setRefHandle() function. now lets see &lt;fb:ref /&gt;s in action. the following code will create a &lt;fb:ref /&gt; and you can later use it anywhere in your application. remember, once created the ref objects are in application scope. and until you change the content again using fbml_setRefHandle() api, it will remain the same.</p>
<pre name="code" class="php">

&lt;?php
include &quot;config.php&quot;;
$handle = &quot;greetings&quot;;
$markup = &quot;Hello &lt;fb:name uid=&#039;{$uid}&#039; /&gt; &quot;;
$facebook-&gt;api_client-&gt;fbml_setRefHandle($handle, $markup);
?&gt;
</pre>
<p>now you can use it anywhere in your application like this </p>
<pre name="code" class="html">

&lt;fb:ref handle=&quot;greetings&quot; /&gt;
</pre>
<p>it will say &quot;Hello &lt;User&#8217;s Name&gt;&quot;</p>
<p>but wait, there is a major disadvantage with this type of handlers and that is the content of this ref object is cached. say, while creating the ref object if the $uid was, for example 503274632 (which is my id) &#8211; when I will come to a page that used this &quot;greetings&quot; ref object, I will see that the out put is &quot;Hello you&quot; and that is expected. Now when another user see the same page he will see that the output is &quot;Hello Hasin Hayder&quot;, but this was not expected. Look, here it didn&#8217;t update the content according to the new user. Because the content of this ref object will remain cached until u change it again using fbml_setRefHandle() api. </p>
<p>to over come this problem and to make these ref objects more usable, you can use url type ref objects. lets see below, you have to use fbml_refreshRefUrl() api. </p>
<pre name="code" class="php">

&lt;?php
include &quot;config.php&quot;;
$url = &quot;http://sandbox.ofhas.in/fbtest/ru.php?uid={$uid}&quot;;
$facebook-&gt;api_client-&gt;fbml_refreshRefUrl($url);
?&gt;
</pre>
<p>and the content of <b>ru.php</b> is </p>
<pre name="code" class="php">

Hello from an external Url &lt;fb:name uid=&quot;&lt;?=$_REQUEST[&#039;uid&#039;];?&gt;&quot; useyou=&quot;false&quot; /&gt;
</pre>
<p>now you can use this url type ref object anywhere in your application, like this</p>
<pre name="code" class="html">

Greetings! &lt;fb:ref url=&quot;&lt;?=$url;?&gt;&quot; /&gt;
</pre>
<p>now if you want to update content of your user&#8217;s profile box offline. Just print any url type ref handler in his profile box using profile_setFBML() api. later, on the time of updating all you have to do is call fbml_refreshRefUrl() so that facebook re cache the content of this url. and regardless to say that your url will deliver all the updated content to display on yoru profiles. your url will always get the user id via &#8220;uid&#8221; parameter in HTTP GET, so you can decide easily what to deliver. </p>
<p>if you are still confused or have any question, don&#8217;t forget to write it as a comment. in next article I am coming with &#8220;how to successfully keep record of all the users of your applications and how to remove them successfully when they remove your app&#8221; &#8211; stay tuned. </p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/04/updating-profile-box-using-fbref/feed/</wfw:commentRss>
		<slash:comments>11</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>
		<item>
		<title>publishing on your friend&#8217;s mini feed (no session key)</title>
		<link>http://fbcookbook.ofhas.in/2009/02/02/publishing-on-your-friends-mini-feed-no-session-key/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/02/publishing-on-your-friends-mini-feed-no-session-key/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 08:58:31 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[Feed]]></category>
		<category><![CDATA[MiniFeed]]></category>
		<category><![CDATA[multiFeedStory]]></category>
		<category><![CDATA[Wall]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=10</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/02/publishing-on-your-friends-mini-feed-no-session-key/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'publishing on your friend&#8217;s mini feed (no session key)';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
the way superpokey or other applications do this, first they ask you to select some friends from your friends list, then they ask you to publish on their wall. at this stage a popup dialog opens up and asks if you really want to publish that story on your friend&#8217;s wall. if you agree, the [...]]]></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/02/publishing-on-your-friends-mini-feed-no-session-key/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'publishing on your friend&#8217;s mini feed (no session key)';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>the way superpokey or other applications do this, first they ask you to select some friends from your friends list, then they ask you to publish on their wall. at this stage a popup dialog opens up and asks if you really want to publish that story on your friend&#8217;s wall. if you agree, the news goes straight to your friend&#8217;s wall. </p>
<p>so how do they do it? you know the publishActionOfUser() actually publish feed&#8217;s on your wall, but there&#8217;s no guaranty if the news will go to your friend&#8217;s news section. so to do this, you have to use feedStoryForm. this form was introduced in facebook old profile, but comes in a new flavor when the profile section is completely redesigned by facebook. feedForms are used to publish news on user&#8217;s mini feed as well as his/her friend&#8217;s wall. but it always asks the user to authorize the publishing of news first. lets see how it actually works</p>
<p><b>step 1: register feed template</b><br />
first, you have to register a feed bundle for your application. later we will use that feed bundle for publishing stories. so lets open  <a href="http://developers.facebook.com/tools.php?feed">feed console</a> and select your application. feed console is accessible at http://developers.facebook.com/tools.php?feed</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-4.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-4-300x238.png" alt="picture-4" title="picture-4" width="300" height="238" class="alignnone size-medium wp-image-12" /></a></p>
<p> now click on next. in the next screen you have to input a one line feed template. to check if you template is valid, you can also input sample data to pass to this template as &#8220;template data&#8221; which is infact a valid json object. lets do this</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-11.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-11-300x207.png" alt="one line feed story" title="one line feed story" width="300" height="207" class="alignnone size-medium wp-image-29" /></a></p>
<p><strong>note one thing that to share a feed with friends, you must put {*target*} token in the one line feed templates.</strong> </p>
<p>our one line feed template is: {*actor*} is publishing some news about {*subject*} on friends wall and he wants to share it with {*target*}<br />
parameters are: {&#8221;subject&#8221;:&#8221;fishing&#8221;}</p>
<p>now click on next to create short story template.<br />
<a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-12.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-12-300x246.png" alt="short story template" title="short story template" width="300" height="246" class="alignnone size-medium wp-image-30" /></a></p>
<p>short story title template: {*actor*} is sharing some news about {*subject*} with {*target*}<br />
short story body template: {*content*}</p>
<p>params: {&#8221;subject&#8221;:&#8221;fishing&#8221;, &#8220;content&#8221;:&#8221;The fishing goes superb in this sunny weather&#8221;}</p>
<p>now click on the &#8220;Update Preview&#8221; to check the validity of our short story feed. If it&#8217;s valid, lets proceed to next step of &#8220;Full Story Template&#8221; by clicking next. both short story and full story feeds are optional. this time we will skip full story template. so on the next screen just click &#8220;skip&#8221; and proceed to final screen. </p>
<p>now we are on the final screen of &#8220;Creating Action Link&#8221;. lets understand what is action link. check the following picture for details of our parameters and how it will appear on your friends wall. </p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-13.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-13-300x226.png" alt="action link" title="action link" width="300" height="226" class="alignnone size-medium wp-image-31" /></a></p>
<p>ok, we are done &#8211; now click on next and on the following screen click on &#8220;Register Template Bundle&#8221;,  a popup dialog box will confirm you that the feed has been created and it will also show you the id of this feedbundle. note that id. </p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-14.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-14-300x240.png" alt="feed bundle id" title="feed bundle id" width="300" height="240" class="alignnone size-medium wp-image-32" /></a></p>
<p><b>step 2: include the feedStoryForm in your application </b><br />
as we have our feed bundle registered, now it&#8217;s time to go into action. lets include the feed form in our application. here&#8217;s the code</p>
<pre name="code" class="php">

&lt;?php

require_once &#039;config.php&#039;;

// Greet the currently logged-in user!
echo &quot;&lt;p&gt;Hello, &lt;fb:name uid=\&quot;{$uid}\&quot; useyou=\&quot;false\&quot; /&gt;, Its story time&lt;/p&gt;&quot;;
?&gt;
&lt;form method=&quot;post&quot;
          fbtype=&#039;multiFeedStory&#039;
          action=&#039;http://sandbox.ofhas.in/fbtest/feedstory.php&#039;&gt;   

	&lt;b&gt;What&#039;s it all about?&lt;/b&gt;&lt;br/&gt;
           &lt;input size=&quot;50&quot; type=&quot;text&quot; name=&quot;subject&quot; id=&quot;subject&quot; value=&quot;&quot; /&gt;&lt;br/&gt;
           &lt;b&gt;Ok! tell your friends more about this&lt;/b&gt;&lt;br/&gt;
	&lt;textarea cols=&quot;50&quot; rows=&quot;8&quot;  name=&quot;content&quot; id=&quot;content&quot; &gt;&lt;/textarea&gt;&lt;br/&gt;
	&lt;b&gt;Thats cool, so whom do you want to inform about it?&lt;/b&gt;
	&lt;div style=&quot;margin:10px 0 10px 0&quot;&gt;
		&lt;fb:multi-friend-selector condensed=&quot;true&quot; /&gt;
	&lt;/div&gt;
	&lt;input type=&quot;submit&quot; value=&quot;Publish News&quot; label=&quot;Publish News&quot; &gt;

&lt;/form&gt;
&lt;script&gt;
function shareDone()
{
     new Dialog().showMessage(&quot;Info&quot;,&quot;Successfully shared your news with your friends&quot;);
}
&lt;/script&gt;
</pre>
<p>output will be something like this</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-10.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-10-300x226.png" alt="output" title="output" width="300" height="226" class="alignnone size-medium wp-image-28" /></a> </p>
<p>the config.php just initiated the facebook object, so nothing to mention about that. but now we have to code the handler of the feed story request that facebook will make when your users will hit the &#8220;Publish News&#8221; button. </p>
<p><b>step 3: feed story handler </b><br />
this file will be invoked internally by facebook over http. in this file you have to process the parameters of yoru feed form and return a valid response to facebook as a json object so that facebook can proceed further to publish your user&#8217;s news. lets see how it works &#8211; here&#8217;s the code</p>
<pre name="code" class="php">

&lt;?php
$subject = $_REQUEST[&#039;subject&#039;];
$content = $_REQUEST[&#039;content&#039;];
$actionsubject= $subject;
?&gt;
{&quot;content&quot;: {&quot;next_fbjs&quot;:&quot;shareDone();&quot;,
                   &quot;feed&quot;: {&quot;template_id&quot;:48644843809,
                                &quot;template_data&quot;: {&quot;subject&quot;:&quot;&lt;?=$subject;?&gt;&quot;,
                                                            &quot;content&quot;:&quot;&lt;?=$content;?&gt;&quot;,
                                                            &quot;actionsubject&quot;:&quot;&lt;?=$actionsubject;?&gt;&quot;} } },
 &quot;method&quot;:&quot;multiFeedStory&quot; }
</pre>
<p>So we are done!</p>
<p>now when user&#8217;s will click on &#8220;Publish News&#8221; button after selleting friends, he will see a dialog box pops up for the authorization to publish the news &#8211; like this</p>
<p><a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-15.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-15-300x193.png" alt="picture-15" title="picture-15" width="300" height="193" class="alignnone size-medium wp-image-33" /></a></p>
<p>user can select whether he wants to publish &#8220;short&#8221; or &#8220;one&#8221; line feed story. remember we had skipped the full story template? if we created full story template, user will get another option like &#8220;full&#8221; in this dialog box. so when this dialog box pops up, user will have to click &#8220;Publish&#8221; to publish the story. </p>
<p>check out the published feed on your friend&#8217;s wall<br />
<a href="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-16.png"><img src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/picture-16-300x152.png" alt="picture-16" title="picture-16" width="300" height="152" class="alignnone size-medium wp-image-44" /></a></p>
<p>let us know your comment if you like our article. we are coming with new recipe soon. </p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/02/publishing-on-your-friends-mini-feed-no-session-key/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>hello fb cookbook reader</title>
		<link>http://fbcookbook.ofhas.in/2009/02/01/hello-world/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/01/hello-world/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 20:39:45 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=1</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/01/hello-world/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'hello fb cookbook reader';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
hello everyone, we have just launched!
our plan is to make it one stop solution for all your facebook application development needs. you will get answers to all your questions. we will mainly focus on development of applications for facebook, and sometime we will also review interesting applications and their cool features which you might have [...]]]></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/01/hello-world/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'hello fb cookbook reader';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p>hello everyone, we have just launched!</p>
<p>our plan is to make it one stop solution for all your facebook application development needs. you will get answers to all your questions. we will mainly focus on development of applications for facebook, and sometime we will also review interesting applications and their cool features which you might have stumbled upon. </p>
<p>stay with us, we will try to answer all of your questions in this cookbook. </p>
<pre name="code" class="php">

&lt;?php
echo &quot;hello readers of  fbcookbook&quot;;
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/01/hello-world/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
