如何为粉丝和非粉丝显示不同的iframe应用?

时间:2011-09-23 22:44:01

标签: facebook iframe facebook-graph-api

如何在不询问用户静态Iframe选项卡应用程序(http://www.facebook.com/iframehost)等权限的情况下,为网页的粉丝和非粉丝显示不同的iframe应用程序?

2 个答案:

答案 0 :(得分:2)

查看从所谓的“signed request”获得的Facebook数据。有一个符合您需求的标志(如果用户喜欢该页面,则为true,否则为false)。

答案 1 :(得分:0)

这是签名请求检查的代码:

$signed_request = $_REQUEST['signed_request'];
function parsePageSignedRequest(){

if (isset($_REQUEST['signed_request'])){
 $encoded_sig = null;$payload = null;
 list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
 $sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
 $data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
 return $data;
}
return false;
}

if($signed_request = parsePageSignedRequest()){
  if($signed_request->page->liked) {
// put your "Liked Page Content Here" 
  } else {
// put your "Alternate" Page Content Here.
  }
}