php 将自定义参数传递给 Facebook 粉丝页面选项卡
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5019115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
passing custom parameters to facebook fan page tab
提问by sreejith
I'm unable to get custom parameters send to my facebook fan page tab.
我无法将自定义参数发送到我的 Facebook 粉丝页面选项卡。
I'm using php and is passing like this:
我正在使用 php 并且是这样传递的:
http://www.facebook.com/pages/{page-name}/?sk=APP_ID&pass=1
http://www.facebook.com/pages/{page-name}/?sk=APP_ID&pass=1
but I'm unable to read the parameter pass
但我无法读取参数传递
Sreejith
斯里吉斯
回答by Plastic Sturgeon
Facebook passes in your data as part of the signed_Request data. Here is how you would retrieve it using PHP:
Facebook 将您的数据作为signed_Request 数据的一部分传入。以下是使用 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;
?>
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.
此示例需要 Facebook PHP api,并将您的 app_data 写入浏览器窗口,您可以在其中惊叹它的所有荣耀。
回答by Skwerl
Oh wow, I didn't know about the app_data parameter.
Here's another method for whatever it's worth:
http://iamskwerl.com/tech/2011/11/passing-query-variables-to-facebook-fan-page-tabs/
哇哦,我不知道 app_data 参数。
这是另一种有价值的方法:http:
//iamskwerl.com/tech/2011/11/passing-query-variables-to-facebook-fan-page-tabs/
回答by Inam Abbas
There is a solution available although I have not tried it but hope it works http://ikorolchuk.blogspot.com/2011/03/facebook-fan-page-pass-parameter-to.html
有一个可用的解决方案,虽然我还没有尝试过,但希望它有效 http://ikorolchuk.blogspot.com/2011/03/facebook-fan-page-pass-parameter-to.html