我想制作一个 facebook 应用程序,当用户单击图像时,会在用户的墙上自动发布一些文本。
我有一个脚本:
<?php
define('FB_APIKEY', 'YOUR_API');
define('FB_SECRET', 'YOUR_SECRET');
define('FB_SESSION', 'YOUR_SESSION');
require_once('./files/Facebook.php');
echo "post on wall";
try {
$facebook = new Facebook(FB_APIKEY, FB_SECRET);
$facebook->api_client->session_key = FB_SESSION;
$fetch = array(
'friends' =>array(
'pattern' => '.*',
'query' => "select uid2 from friend where uid1={$user}"
)
);
echo $facebook->api_client->admin_setAppProperties(array('preload_fql' => json_encode($fetch)));
$message = 'From My App: publish steven on facebook';
if( $facebook->api_client->stream_publish($message))
echo "Added on FB Wall";
} catch(Exception $e) {
echo $e . "<br />";
}
?>
据我了解,我需要输入名为“YOUR_API”、“YOUR_SECRET”、“YOUR_SESSION”的 api、秘密和会话。
但是我怎样才能得到我的会话密钥呢?
当我输入 API 时,SECRET 正确,但没有会话密钥我得到错误:
Fatal error: Call to a member function stream_publish() on a non-object in /home/padekime/domains/padekime.wu.lt/public_html/scriptas/index.php on line 12
我花了很多时间,阅读了很多教程,但没有找到解决方案......
也许这里有任何其他脚本可以在用户的墙上发布一些文本?
当我尝试此解决方案时: 为状态更新授权 Facebook 粉丝页面时 出现错误:
FATAL error (Fatal error: Call to a member function stream_publish() on a non-object in ...)
当我尝试这个时:
<?php
$msg = array (
'message' => 'bla bla bla ... bla bla bla...',
'name' => 'The BlaBla Mesage',
'caption' => 'link',
'link' => 'http://www.google.lt',
'description' => 'saf',
'picture' =>'',
'actions' => array(array(
'name' => 'Visit',
'link' => 'http://www.google.lt'))
);
$result = $facebook->api('/me/feed/','post',$msg);
var_dump($result);
?>
我收到错误:
Fatal error: Call to a member function api() on a non-object in /home/padekime/domains/padekime.wu.lt/public_html/scriptas/index.php on line 22
谢谢你的帮助。