Facebook Dashboard API.... fail to use it :|

admin

Administrator
Staff member
This question is about <strong>Dashboard.addNews</strong> and <strong>Dashboard.publishActivity</strong>

Facebook has told the public about its new Dashboard API, however it hasn't provided any updates on its library to use the new code.

So I followed the advice in this link
<a href="http://forum.developers.facebook.com/viewtopic.php?pid=197753" rel="nofollow noreferrer">http://forum.developers.facebook.com/viewtopic.php?pid=197753</a>
to add the new functions to the facebookapi_php5_restlib.php

Code:
//dashboard functions
  public function dashboard_addNews($uid, $news, $image = null) { 
    return $this-&gt;call_method('facebook.dashboard.addNews',
                              array('uid' =&gt; $uid,
                                    'news' =&gt; $news,
                                    'image' =&gt; $image));
  }

  public function dashboard_multiAddNews($uids, $news, $image = null) { 
    return $this-&gt;call_method('facebook.dashboard.multiAddNews',
                              array('uids' =&gt; $uids ? json_encode($uids) : null,
                                    'news' =&gt; $news,
                                    'image' =&gt; $image));
  }

  public function dashboard_addGlobalNews($news, $image = null) {
    return $this-&gt;call_method('facebook.dashboard.addGlobalNews',
                              array('news' =&gt; $news,
                                    'image' =&gt; $image));
  }

  public function dashboard_publishActivity($activity, $image = null) {
    return $this-&gt;call_method('facebook.dashboard.publishActivity',
                              array('activity' =&gt; $activity,
                                    'image' =&gt; $image));
  }

  public function dashboard_multiIncrementCount($uids) {
    return $this-&gt;call_method(
      'facebook.dashboard.multiIncrementCount', array('uids' =&gt; json_encode($uids)));
  }

  public function dashboard_removeActivity($activity_ids) {
    return $this-&gt;call_method(
      'facebook.dashboard.removeActivity', array('activity_ids' =&gt; json_encode($activity_ids)));
  }

  public function dashboard_setCount($uid, $count) {
    return $this-&gt;call_method('facebook.dashboard.setCount',
                              array('uid' =&gt; $uid,
                                    'count' =&gt; $count));
  }

But now when I follow the sample code at
<a href="http://wiki.developers.facebook.com/index.php/Dashboard.addNews" rel="nofollow noreferrer">http://wiki.developers.facebook.com/index.php/Dashboard.addNews</a>

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

However it will prompt this error:

Code:
[Wed Jan 27 03:42:27 2010] [error] [client 127.0.0.1] PHP Notice:  Array to string conversion in /var/local/site/webroot/xxxx/facebookapi_php5_restlib.php on line 2009

the code at that php line is

Code:
if (is_array($val)) $val = implode(',', $val);

pls notice that I haven't altered the facebookapi_php5_restlib.php except pasting those suggested dashboard function code.

and when I follow the instruction at <a href="http://wiki.developers.facebook.com/index.php/Dashboard.publishActivity" rel="nofollow noreferrer">http://wiki.developers.facebook.com/index.php/Dashboard.publishActivity</a> and try to use it:

Code:
$image = 'http://www.martialdevelopment.com/wordpress/wp-content/images/cheezburger-or-dim-mak.jpg'; 
$activity = array(array('message' =&gt; '{*actor*} just sponsored @:563683308!', 'action_link' =&gt; array('text' =&gt; 'Sponsor this cause', 'href' =&gt; 'http://www.example.com/games?id=5878237'))); 
$facebook-&gt;api_client-&gt;dashboard_publishActivity($activity, $image);

it throws out the same error too about "Array to string conversion"

Any suggestion to actually use the new Facebook Dashboard API?