<?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; API</title>
	<atom:link href="http://fbcookbook.ofhas.in/tag/api/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>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 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>
