Facebook 权限对话框(JavaScript sdk)

发布于 2024-12-11 04:21:34 字数 1159 浏览 0 评论 0原文

我正在使用 OAuth Dialog 获取 Facebook 权限来访问用户的电子邮件、生日和其他详细信息,但是当我运行此应用程序时,URL 为 https://apps.facebook.com/projectatestapp/ (同时登录 Facebook)我看到登录应用程序窗口显示:

您正在以 Nina Sewart 身份登录 testapp。登录不会将此应用的活动添加到 Facebook。

使用登录和取消按钮而不是带有允许和不允许按钮的权限窗口

这是我的代码

<html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <div id="fb-root"></div>
    <script>
        FB.init({ 
            appId: '[My app id]', 
            xfbml: true, 
            cookie: true,
            oauth: true
        });

        FB.login({
            scope: 'email,user_birthday',
        });
    </script>

    <a href="https://www.facebook.com/dialog/oauth/?scope=email,
        user_birthday&
        client_id=148244388606048&
        redirect_uri=https://apps.facebook.com/projectatestapp/test2.html&
        response_type=token" target="_top">test</a>
</body>
</html>

请告诉我它有什么问题吗?

I am using OAuth Dialog for Facebook permission to access a users' email, birthday and other details but when I run this app URL that is https://apps.facebook.com/projectatestapp/ (while being logged into Facebook) I see this login to app window which says:

You are logging into testapp as Nina Sewart. Logging in will not add this app's activity to Facebook.

With log in and cancel button instead of Permission window with Allow and Don't Allow button

here is my code

<html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <div id="fb-root"></div>
    <script>
        FB.init({ 
            appId: '[My app id]', 
            xfbml: true, 
            cookie: true,
            oauth: true
        });

        FB.login({
            scope: 'email,user_birthday',
        });
    </script>

    <a href="https://www.facebook.com/dialog/oauth/?scope=email,
        user_birthday&
        client_id=148244388606048&
        redirect_uri=https://apps.facebook.com/projectatestapp/test2.html&
        response_type=token" target="_top">test</a>
</body>
</html>

Please tell me whats wrong in it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

南风几经秋 2024-12-18 04:21:34

您看不到它的原因是申请过程已变成一个两步过程。

  1. 该人接受登录您的应用程序。
  2. 作为接受您的扩展权限的人,这就是回调 url 发挥作用的地方。

可以在此处找到文档。

所以你的回调没有被调用的原因是因为两步过程。我建议将响应附加到调用的第二页上。

我不确定 JS SDK 是如何工作的,但这就是我设法做到的。

祝你好运。

The reason you are not seeing it is because the application process has become a two step process.

  1. Being that the person accepts to login into your application.
  2. Being the person accept your extended permission which is where the callback url comes into play.

Documentation can be found here.

So the reason your callback isn't being called is because the two step process. I would suggest making the response attached to second page that is called.

I am not sure how the JS SDK works but it is how I managed to do it.

Goodluck.

雄赳赳气昂昂 2024-12-18 04:21:34

您需要在调用授权窗口之前将 fb 令牌添加到 url 中,以识别您的 fb 用户。

我想尝试这个来获取令牌:FB.getAccessToken();

You need before calling autorization window to add the fb token to the url to identify your user to fb.

I think try this to get the token : FB.getAccessToken();

烟火散人牵绊 2024-12-18 04:21:34

我这里也有同样的问题。文档说只有这个应用程序的开发人员/测试人员才能获得发布权限,但我可以设法使其仅与用于创建应用程序的 ID 一起使用。其他测试用户(即使是授权开发人员)无法通过“添加到时间线”阶段。

这可能是一个重大错误。

I have the same issues here. The documentation says only developers/tester of this app will be able to get the publish permission but I could manage to make it work only with the id that was used to create the app. Other test users (even though are authorized developers) are not able to get past the 'add-to-timeline' stage.

It could be a major bug.

£噩梦荏苒 2024-12-18 04:21:34

我在这个问题上苦苦挣扎了几个小时,我可爱的同事刚刚帮我解决了它。确保调用登录后不要刷新页面。基本上,不要执行如下操作:

FB.login(...);
window.location.refresh();

将刷新代码包含在 FB.login 的回调中!

伙计,我觉得很愚蠢,但有时你会感到困惑,忘记回调在代码执行顺序方面是如何工作的。

I was struggling with this issue for few hours, and my lovely co-worker helped me fix it just now. Make sure you don't refresh the page after login was called. Basically, don't do something like below:

FB.login(...);
window.location.refresh();

Include the refresh code inside of the callback for FB.login!

Man, I feel so stupid, but sometimes you get confused and forget how callbacks work in terms of execution orders of code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文