[英]Facebook canvas authentication by referral
I have been stuck with this problem for a while now, and I just gave up today, I realized I really badly need help, and i couldn't find any posts addressing a similar issue.. so 我已经被这个问题困扰了一段时间了,今天我才放弃了,我意识到我真的很需要帮助,而我找不到解决类似问题的任何帖子。
I am trying to create a facebook app (since jan 1 2012 - incase there has been any standards change, you guys can tell me about it), and I have properly set my canvas url. 我正在尝试创建一个Facebook应用(自2012年1月1日起-万一发生任何标准更改,你们可以告诉我),并且我已经正确设置了我的画布网址。
So right now when you visit my app on facebook, as apps.facebook.com/canvas-page you can see my app. 因此,当您现在在Facebook上访问我的应用程序时,如apps.facebook.com/canvas-page,您可以看到我的应用程序。 However I am having problem with authentication.
但是我在身份验证方面遇到问题。
My app requires basic information, and email address of the user trying to access it. 我的应用程序需要基本信息,以及尝试访问它的用户的电子邮件地址。
So as far as I have gotten so far, I have set it so that new users can see the authentication dialog and then visit my app. 到目前为止,我已经进行了设置,以便新用户可以看到身份验证对话框,然后访问我的应用程序。 On visiting my app I want my app to be able to access the information as I stated above.
访问我的应用程序时,我希望我的应用程序能够访问如上所述的信息。 However on my canvas page I did the following for code in php, and nothing else, I want to be able to see what information is passed on to my app by the facebook referral from the authentication dialog:
但是,在我的画布页面上,我对php中的代码做了以下操作,除此之外,我希望能够看到通过身份验证对话框中的facebook引用将哪些信息传递给我的应用程序:
<?php
print_r($_GET);
echo "\n";
print_r($_POST);
?>
However sadly this is giving me empty arrays, and nothing else. 但是可悲的是,这给了我空数组,没有别的。
All I really need for my Facebook app is the access_token, and the user id, although I am pretty sure I can access the current user's id by visiting graph.facebook.com/me?access_token=[access token provided from somewhere] 我的Facebook应用程序真正需要的只是access_token和用户ID,尽管我非常确定我可以通过访问graph.facebook.com/me?access_token= [从某处提供的访问令牌]来访问当前用户的ID。
so thats my first problem, second problem is that when I logout of facebook and I visit apps.facebook.com/canvas-page I don't get asked to login, why is that so? 因此,这是我的第一个问题,第二个问题是,当我注销Facebook并访问apps.facebook.com/canvas-page时,没有提示我登录,为什么会这样? Do I have to redirect to Facebook using JavaScript to login and then refer to my app?
我是否必须使用JavaScript重定向到Facebook才能登录,然后引用我的应用程序?
Currently these are my settings (ask for more info so that i can give them to you) Settings > Auth Dialog > Authenticated referrals > User & Friend permission = email Settings > Auth Dialog > Authenticated referrals > Auth Token parameter = ?code= 目前,这些是我的设置(向我询问更多信息,以便我可以将其提供给您)设置>身份验证对话框>身份验证的引荐>用户和朋友权限=电子邮件设置>身份验证对话框>身份验证的引荐> Auth令牌参数=?code =
Settings > Advanced > migrations = ALL ENABLED 设置>高级>迁移=全部启用
FB use Signed Request to send data to your app (not $_POST, not $_GET). FB使用签名请求将数据发送到您的应用程序(不是$ _POST,不是$ _GET)。 There is a chapter called
signed_request Parameter
in Sample Canvas App that talk about it. Sample Canvas应用程序中有一章称为
signed_request Parameter
。
Using php-sdk you can obtain it like this: 使用php-sdk可以像这样获得它:
$signed_request = $facebook->getSignedRequest();
var_dump($signed_request);
array (
'algorithm' => 'HMAC-SHA256',
'expires' => 1326632400,
'issued_at' => 1326628636,
'oauth_token' => '***',
'page' =>
array (
'id' => '***',
'liked' => false,
'admin' => true,
),
'user' =>
array (
'country' => 'cl',
'locale' => 'en_US',
'age' =>
array (
'min' => 21,
),
),
'user_id' => '***',
)
Besides you can pass a parameter called app_data
through URL: 此外,您可以通过URL传递一个名为
app_data
的参数:
"http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here"
You will get it in the $signed_request
too. 您也将在
$signed_request
得到它。
...
array (
'algorithm' => 'HMAC-SHA256',
'app_data' => 'any_string_here',
'expires' => 1326636000,
'issued_at' => 1326629411,
...
Please comment! 请评论! Thanks.-
谢谢。-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.