How to use dashboard api of facebook


facebookRecently facebook introduced 2 new features in homepage. If you look carefully on the left side you’ll see two new buttons:

Applications
Games

These are called dashboards. So what is the purpose of these 2 dashboards?

  1. Using dashboards users can discover and engage with your applications on facebook
  2. Users can know which applications are used by their friends
  3. An application can easily publish a particular news for a particular user
  4. An application can also publish global news, so that all users of that application be informed

facebook-dashboard

A typical games dashboard looks like this

facebook-games-dashboard

Application dashboard almost similar like games dashboard. So facebook dashboard now becomes another viral features and to market your application you should integrate dashboard api in your application.

Lets have a look what features we will get using dashboard api. And before testing these apis first update the facebook library by replacing your old facebook library by  latest facebook library

News Items

You can make announcements to your users by sending them news in dashboard. There are 2 types of news you can set for your users:

sample code

//global news
$news = array(array('message' => 'There is a new level in the dungeon game!',
                    'action_link' => array('text' => 'Play now.',
                                           'href' => 'http://www.example.com/gifts?id=5878237')));
$image = 'http://www.martialdevelopment.com/wordpress/wp-content/images/cheezburger-or-dim-mak.jpg';

$facebook->api_client->dashboard_addGlobalNews($news, $image);

//news for a particular user
$image = 'http://www.martialdevelopment.com/wordpress/wp-content/images/cheezburger-or-dim-mak.jpg';
$news = array(array('message' => 'Your friend @:563683308 just sent you a present!',
                    'action_link' => array('text' => 'Get Your Gift',
                                           'href' => 'http://www.example.com/gifts?id=5878237')));

$facebook->api_client->dashboard_addNews($news, $image, $toUser);

So when user will visit dashboard they will see the news items appear in the news stream — where users’ recent games/applications appear on the dashboard.

The following methods pertain to news items for a single user.

The following methods pertain to news items for all your users.

Setting News for Multiple Users (Performance Optimization)

User Activity

You can broadcast the activity of your users publicly, to inform their friends of actions they’ve taken recently with applications and games. These activities will appear in the activity stream — where users’ recent activity appears on the dashboard. Facebook says that this is an experimental feature and they may change it. So take a look periodically Live Status

The API methods used for user activities are:

//sample code
$activity = array('message' => '{*actor*} just sent a gift to his friend @:563683308!',
                  'action_link' => array('text' => 'Gift Shop',
                                         'href' => 'http://apps.facebook.com/yourapp/gift'));
$facebook->api_client->dashboard_publishActivity($activity);

Counter

Using dashboard api you can set the counters that appear next to your application bookmark under the profile picture (if the user bookmarked the application). The counter informs the user in a lightweight way to take an action in your application. Keep in mind, unless user bookmarked your application, they will not see this counter. So first inspire your user to bookmark your application. Checkout my previous article Inspire your user to bookmark your application.

facebook counter

After you set the counter for a user, Facebook clears the counter when the user visits your application’s bookmark URL. But if the application is a facebook connect site,  then you must call dashboard.setCount (and set the count to 0) to reset the counter when user visit the bookmark url.

The following methods pertain to counters for a single user.

For multiple users you should use these methods:

Sample code:

//set a counter to the logged in user
$stat = $facebook->api_client->dashboard_setCount(1);

//if you want to set counter to a particular user provide the 2nd parameter $toUser
//$stat = $facebook->api_client->dashboard_setCount(1, $toUser);

if ($stat){
    echo 'counted';
}
else{
    echo 'not counted';
}

So if you’re not already implemented these new features for your applications, you should implement these asap to promote your applications to facebook users. A single viral feature of facebook may increase lots of users for your application.

Hope this article will help you. 🙂

mahmud ahsan

Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

You may also like

5 Comments

  • ranacse05
    April 18, 2010 at 6:09 pm

    very nice article . I was about to write this 🙂

    thanks again to save my time.

  • jimena
    June 3, 2010 at 1:17 am

    great article, very helpful.
    newb here and still have questions:
    where do i paste the sampe code?
    how do i add in the future new news? just add a new message to the file and then pubblish it and it will auto appear on the dashboard?

    Please help! since this is so new, there’s barely anything helpful online.

    Thanx a lot!

  • hasan yilmaz
    September 17, 2010 at 4:42 am

    hi, i have some apps and i want to add dashboard api. i am using graph api all my apps.
    i tried this code but i think grap api doesnt support.
    can we use dashboard api with grap api.
    if we can use pls help 🙁

  • Juanito
    October 11, 2010 at 5:57 pm

    I have a problem similar to hasan’s.

    Well, i have actually used the method the following way, but it returns an error.

    $news[]=array(‘message’ => ‘my news’);
    $param = array(
    ‘method’ => ‘dashboard.addGlobalNews’,
    ‘news’ => $news
    );
    try{
    $sentnews = $facebook->api($param);
    }catch (FacebookApiException $e){
    echo $e;
    }

    The error:

    Exception: 15: The method you are calling or the FQL table you are querying cannot be called using a session secret or by a desktop application.

    Im not using it from a desktop aplication. Does somebody know how to omit sending the session secret and send the application key?

    Thanks,

  • Kamesenin Butan
    May 6, 2012 at 5:35 pm

    Dashboard API is no longer supported.

Comments are closed here.

About Me

Hi I am Mahmud Ahsan. I Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

Twitter Feed

Fanpage