将自定义参数传递给 Facebook 粉丝页面选项卡

我无法将自定义参数发送到我的 Facebook 粉丝页面标签.

I'm unable to get custom parameters send to my facebook fan page tab.

我正在使用 php 并且是这样传递的:

I'm using php and is passing like this:

http://www.facebook.com/pages/{page-name}/?sk=APP_ID&pass=1

http://www.facebook.com/pages/{page-name}/?sk=APP_ID&pass=1

但我无法读取参数传递

斯瑞吉斯

推荐答案

Facebook 将您的数据作为 signed_Request 数据的一部分传入.以下是使用 PHP 检索它的方法:

Facebook passes in your data as part of the signed_Request data. Here is how you would retrieve it using PHP:

<?php 
require 'facebook.php';
$app_id = "YOUR APP ID HERE";
$app_secret = "YOUR SECRET KEY HERE";


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


// THE MAGIC SAUCE
$signed_request = $facebook->getSignedRequest();

$page_id = $signed_request["page"]["id"];
$like_status = $signed_request["page"]["liked"];
// HERE IS A STRING OF YOUR APP DATA.
$app_data = $signed_request["app_data"];

echo '$app_data = '.$app_data;
?>

这个示例需要 Facebook PHP api,并将您的 app_data 写入浏览器窗口,您可以在其中惊叹它的所有荣耀.

This example requires the Facebook PHP api and will write your app_data into the browser window where you can marvel in all its glory.

相关文章