Facebook 权限对话框(JavaScript sdk)
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您看不到它的原因是申请过程已变成一个两步过程。
可以在此处找到文档。
所以你的回调没有被调用的原因是因为两步过程。我建议将响应附加到调用的第二页上。
我不确定 JS SDK 是如何工作的,但这就是我设法做到的。
祝你好运。
The reason you are not seeing it is because the application process has become a two step process.
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.
您需要在调用授权窗口之前将 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();
我这里也有同样的问题。文档说只有这个应用程序的开发人员/测试人员才能获得发布权限,但我可以设法使其仅与用于创建应用程序的 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.
我在这个问题上苦苦挣扎了几个小时,我可爱的同事刚刚帮我解决了它。确保调用登录后不要刷新页面。基本上,不要执行如下操作:
将刷新代码包含在 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:
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.