开发者

Facebook's pages.isfan requires user id

开发者 https://www.devze.com 2023-03-03 11:29 出处:网络
Basically I would like to know if my visitor is already a fan of my Facebook Page 开发者_运维百科or not.

Basically I would like to know if my visitor is already a fan of my Facebook Page 开发者_运维百科or not.

I tried looking a while and pages.isFan is the best solution so far.

http://developers.facebook.com/docs/reference/rest/pages.isFan/

But pages.isFan need user id (uid), which I can only get if they installed or grant access to my Facebook apps.

My question is, is there a way just to get the uid of my visiting user without ask them to grant access to my Facebook apps?


This code should do the trick:

$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

if (empty($data["page"]["liked"])) {
  /* Not Fan */
}
else {
  /* Fan */
}


More methods can be found here: http://www.masteringapi.com/tutorials/facebook-api-check-if-a-user-is-fan-of-a-facebook-page/20/

0

精彩评论

暂无评论...
验证码 换一张
取 消