您好我想检查用户是否已经成为我的粉丝页面的粉丝。我已经找到了准备好的脚本来做到这一点,但它有很多解析错误。你能帮我解决一下这个代码吗?
<!--?php require('facebook.php');
$config = array(
'appId' =?--> 'your facebook app id',
'secret' => 'your facebook app secret code',
'allowSignedRequest' => false
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
if (isset($user_id)) {
try {
$likes = $facebook->api('/me/likes/your_facebook_page_id_here', 'GET');
if (!empty($likes['data'])) // if user has liked the page then $likes['data'] wont be empty otherwise it will be empty
{
echo 'Thank you for liking our fan page!';
// you can write some custom code here to award users some points or some badge
}
else {
echo 'You have not liked our fan page! Like it now:';
?>
<iframe src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Farkhitech&width&height=290&colorscheme=light&show_faces=true&header=true&stream=false&show_border=true&appId=1392604484339363" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:290px;" allowtransparency="true"></iframe> //replace this with your own Facebook like box code
<!--?php }
} catch (FacebookApiException $e) {
$login_url = $facebook-?-->getLoginUrl();
echo '<a href="' . $login_url . '">Please click here to login into your Facebook account.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
$login_url = $facebook->getLoginUrl();
echo '<a href="' . $login_url . '">Please lick here to login into your Facebook account</a>';
}
?>
答案 0 :(得分:1)
您需要使用user_likes
权限授权用户,然后使用以下API调用:
/me/likes/[page-id]
如您所见,这是您示例代码中的API调用。如果没有完全告诉我们你得到的错误,就无法提供帮助。但无论如何,这无关紧要,因为:
user_likes
,否则它只适用于在App中有角色的用户。 Facebook绝对不会批准它是不允许的。换句话说:不可能也不允许。