Facebook iFrame应用程序重定向 [英] Facebook iFrame application redirect

查看:68
本文介绍了Facebook iFrame应用程序重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Facebook中编写一个应用程序,该应用程序应通过我自己的业务页面上的页面选项卡显示.我需要与查看用户互动,因此我需要扩展权限.

I am writing an application in Facebook that is meant to be shown through a page tab on my own business page. I need to interact with the viewing user, thus I require extended rights.

我已按照建议的步骤进行操作,但现在遇到了麻烦.我的应用程序位于iFrame中,并且对扩展权限的请求使用了重定向.我可以找到需要确认授权的页面,但是当您单击允许时,Facebook重定向到托管我的应用程序的页面,而不是返回到我的Facebook页面选项卡.一旦获得了适当的权限,该应用程序的其余部分就可以正常工作,因此我知道重定向只是一个问题,但是我觉得我已经尝试了所有方法,而且似乎没有很多人遇到相同的问题.如果有人能指出我正确的方向,我会很乐意.

I've followed the suggested procedure but have now hit a wall. My application sits in an iFrame and the request for extended rights uses redirection. I can get the page where you need to confirm authorization but when you click allow, Facebook redirects to the page where my application is hosted instead of back to my Facebook page tab. Once the proper rights have been authorized, the rest of the application works fine so I know it's just a problem with redirection but I feel like I've tried everything and not a lot of people seem to have had the same problem. I would love if anyone could point me in the right direction.

谢谢!

这是我的代码:

$app_id = "myappid";

$canvas_page = "http://wheremyappishosted/";

$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

$user_id = $data["user_id"];
$access_token = $data['oauth_token'];

if (empty($data["user_id"])) {
 $auth_url = "https://graph.facebook.com/oauth/authorize?client_id=".$app_id."&redirect_uri=".urlencode($canvas_page)."&scope=user_photos,friends_photos,publish_stream,user_likes";
 die("<script> top.location.href='" . $auth_url . "'</script>");
}

$f = json_decode(file_get_contents("https://graph.facebook.com/".$user_id."?access_token=".$access_token."&fields=name,albums,likes"), true);

推荐答案

对于那些感兴趣的人,我相信我找到了一种规避此问题的方法.我没有将用户重定向到应用程序,而是将他们重定向到一个小的脚本,该脚本然后重定向回到页面选项卡.由于该应用已获得授权,因此一切正常,并且signed_request与用户信息一起传递.我不知道这是否真的是合法的方法,但确实可行.

For those interested, I believe I have found a way to circumvent this. Instead of redirecting the user back to the application, I redirect them to a small script which then redirects back to the page tab. Since the app has already been authorized, everything works and the signed_request gets passed along with the user infos. I don't know if it's really the legit way to go but it works.

这篇关于Facebook iFrame应用程序重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆