我正在使用facebook功能在接受邀请后从通知和应用程序页面选项卡中删除邀请但是它给了我一个错误。
function build_full_request_id($request_id, $user_id) {
echo $request_id . '_' . $user_id;
}
foreach ($request_ids as $request_id)
{
("reqeust_id=".$request_id."<br>");
$full_request_id = build_full_request_id($request_id, $user_id);
("full_request_id=".$full_request_id."<br>");
try {
$delete_success = $facebook->api("/$full_request_id",'DELETE');
if ($delete_success) {
echo "Successfully deleted " . $full_request_id;}
else {
echo "Delete failed".$full_request_id;}
}
catch (FacebookApiException $e) {
"error";}
}
这是错误,我得在
中的非对象上调用成员函数api()答案 0 :(得分:0)
错误表示您的变量$facebook
不是对象。在代码中找到创建$facebook
的位置,并确保正确生成它。看起来应该是这样的:
$facebook = new Facebook(array(
'appId' => '1231231231231',
'secret' => '12ba5212bae2617267',
));
(显然,它应该有你的appId和秘密,而不是我放在那里的垃圾。)
答案 1 :(得分:0)
$facebook = new Facebook(array(
'appId' => '1231231231231',
'secret' => '12ba5212bae2617267',
));
foreach ($request_ids as $request_id) {
$full_request_id = $request_id."_".$user_id;
try {
$delete_success = $facebook->api('/'.$full_request_id, 'DELETE');
if ($delete_success) {
echo "Successfully deleted ".$full_request_id;
}else{
echo "Delete failed ".$full_request_id;
}
} catch(FacebookApiException $e) {
echo $e->getMessage();
}
}