粉丝门/喜欢页面无法使用新应用

时间:2011-12-21 15:34:20

标签: facebook-like facebook-page

从几天前开始,这个:

<?php $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"])) 
{     
echo "You are not a fan!"; 
} 
else 
{     
echo "Welcome back fan!"; 
} 
?>

不起作用,有谁知道为什么?

1 个答案:

答案 0 :(得分:0)

这很好用:

<?php
$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) { 
//fan content
 } else {
//non-fan content
    }
  }