简体   繁体   English

使用 JS SDK 登录 Facebook 即时游戏

[英]Facebook instant game login with JS SDK

I am trying to upload my game made with React to Facebook Instant games.我正在尝试将我用 React 制作的游戏上传到 Facebook Instant 游戏。 I have facebook login implemented with Facebook JS SDK.我使用 Facebook JS SDK 实现了 facebook 登录。 But facebook instant game runs inside a sandboxed iframe which blocks any popups and I cannot run FB.login().但是 facebook 即时游戏在沙盒 iframe 中运行,该 iframe 会阻止任何弹出窗口,我无法运行 FB.login()。 In instant games docs it says that FB.login should work and it should open a popup in 'async' mode.在即时游戏文档中,它说 FB.login 应该可以工作,并且应该在“异步”模式下打开一个弹出窗口。 But it doesn't.但事实并非如此。 Login popup gets blocked and I get the following error:登录弹出窗口被阻止,我收到以下错误:

Blocked opening ... in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.阻止打开...在新窗口中,因为请求是在沙盒框架中发出的,其“允许弹出窗口”权限未设置。

You are looking for the wrong documentation, which leads to Legacy Web games.您正在寻找错误的文档,这导致了 Legacy Web 游戏。 You need to refer to the Facebook Instant Game SDK to get the user information inside a FB Instant Game.您需要参考Facebook Instant Game SDK来获取FB Instant Game 中的用户信息。 Most importantly FB Instant games don't allow to use of the Facebook Graph API within the FB Instant Game.最重要的是,FB Instant 游戏不允许在 FB Instant Game 中使用 Facebook Graph API。 Although the Graph API offers more capabilities like getting the user gender , the Facebook Instant Game SDK only exposes a limited number of data for developers.尽管 Graph API 提供了获取用户性别等更多功能,但 Facebook Instant Game SDK 仅向开发人员公开了有限数量的数据。 The Facebook Login for the Web with the JavaScript SDK is an OAuth login that cannot be used inside a FB Instant Game.使用 JavaScript SDK 的 Facebook 网页登录是一种 OAuth 登录,不能在 FB Instant Game 中使用。

FYI: Facebook Instant GAme SDK v7.0 doesn't provide all the user information about the user.仅供参考:Facebook Instant GAme SDK v7.0 不提供有关用户的所有用户信息。 It only provides the following data它只提供以下数据

  • Display Name显示名称

    var playerName = FBInstant.player.getName() var playerName = FBInstant.player.getName()

  • Profile Picture个人资料图片

    var playerImage = new Image(); var playerImage = new Image(); playerImage.crossOrigin = 'anonymous'; playerImage.crossOrigin = '匿名'; playerImage.src = FBInstant.player.getPhoto(); playerImage.src = FBInstant.player.getPhoto();

You can only use the above information in your FB instant games.您只能在您的FB即时游戏中使用以上信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM