如何为php Facebook SDK实现扇形门

时间:2012-02-17 12:26:38

标签: php facebook facebook-like facebook-php-sdk

我正在尝试创建一个facebook fangate标签。

我正在使用此代码

<?php 

    // create the Facebook Graph SDK object
    require_once('facebook.php');
    $facebook = new Facebook(array(
        'appId'=>'xxx', // replace with your value
        'secret'=>'xxxxx' // replace with your value
            ));
    $signedRequest = $facebook->getSignedRequest();

    // Inspect the signed request
    if($signedRequest['page']['liked'] == 1){
        echo 'pageid ' + $signed_request["page"]["id"]; 
        include('like.php');

    } else {
        echo 'pageid ' + $signed_request["page"]["id"]; 
        include('noLike.php');

    }
?>

但它似乎工作,页面ID显示为零。它总是显示nolike.php文件。

我也试过这段代码

$app_id = "xxx";
$app_secret = "xxxx";
$facebook = new Facebook(array(
    'appId' => $app_id,
    'secret' => $app_secret,
    'cookie' => true
));

$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];





?>


<?php
if($like_status){
       include('like.php');
    }else{
        include('noLike.php');
 }

?>

这也只显示noLike.php文件

这里是一个类似的页面 http://www.facebook.com/pages/BigDawg-Labs/166258126793251?sk=app_280260608708912

你有什么想法我不能$signed_request["page"]["liked"]总是评估为假

0 个答案:

没有答案