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
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>
However it will prompt this error:
the code at that php line is
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:
it throws out the same error too about "Array to string conversion"
Any suggestion to actually use the new Facebook Dashboard API?
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->call_method('facebook.dashboard.addNews',
array('uid' => $uid,
'news' => $news,
'image' => $image));
}
public function dashboard_multiAddNews($uids, $news, $image = null) {
return $this->call_method('facebook.dashboard.multiAddNews',
array('uids' => $uids ? json_encode($uids) : null,
'news' => $news,
'image' => $image));
}
public function dashboard_addGlobalNews($news, $image = null) {
return $this->call_method('facebook.dashboard.addGlobalNews',
array('news' => $news,
'image' => $image));
}
public function dashboard_publishActivity($activity, $image = null) {
return $this->call_method('facebook.dashboard.publishActivity',
array('activity' => $activity,
'image' => $image));
}
public function dashboard_multiIncrementCount($uids) {
return $this->call_method(
'facebook.dashboard.multiIncrementCount', array('uids' => json_encode($uids)));
}
public function dashboard_removeActivity($activity_ids) {
return $this->call_method(
'facebook.dashboard.removeActivity', array('activity_ids' => json_encode($activity_ids)));
}
public function dashboard_setCount($uid, $count) {
return $this->call_method('facebook.dashboard.setCount',
array('uid' => $uid,
'count' => $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' => '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($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' => '{*actor*} just sponsored @:563683308!', 'action_link' => array('text' => 'Sponsor this cause', 'href' => 'http://www.example.com/games?id=5878237')));
$facebook->api_client->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?