如何将用户信息集成到我的 Facebook 应用程序中?
我用 Javascript 编写了一个应用程序,并将其放在 Facebook 上,现在希望将用户信息集成到游戏中。我希望它类似于 Words with Friends 的工作方式,其中使用用户的姓名和个人资料图片信息来显示分数。为了最好地适应我的应用程序的工作方式,在我看来,能够将名称和图片设置为变量似乎是执行此操作的最佳方法。理想情况下,我还想采用一种方法,从用户朋友的菜单中选择他们想要挑战的朋友并发送请求,并记录用户的赢/输统计数据。我四处搜寻,但找不到任何有关如何执行此操作的指南。如果有人可以向我指出一个或向我提供执行此操作的代码,那就太好了。我对编程有点陌生,对 Facebook 应用程序完全陌生。
这是我到目前为止所拥有的链接:https://apps.facebook.com/dotsandboxesgame。
I wrote an application in Javascript that I put on facebook and would now like to integrate user information into the gameplay. I would like it to be similar to the way Words with Friends works, where the users' name and profile picture information are used to display the scores. To work best with the way my application works, being able to set the name and picture as variables seem to me to be the best way of doing this. Ideally I would also like to incorporate a way to select from a menu of the users friends which friend they want to challenge and send a request, and also record the users win/loss statistics. I have searched around and have not been able to find any guides on how to do this. If someone could point me to one or provide me with the code to do this that would be really great. I am somewhat new to programming and entirely new to Facebook applications.
Here is a link to what I have so far: https://apps.facebook.com/dotsandboxesgame.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个很大的主题,需要您深入研究我假设您已经看过的图形 API。如果您还没有,请点击链接
https://graph.facebook.com/
基本上,您需要请求 Facebook 用户允许做某些事情。您希望能够使用他们的帐户执行的操作将与您的应用程序的操作一致。当用户接受这些权限时,您将拥有一个访问令牌,您可以在查询字符串中使用该令牌来查询图形 API,以获取有关该人的任何可用数据(受您向他们请求的权限的限制)。
然后由您的代码来解释该数据(JSON 或 XML),然后显示它、与其交互等。
请注意,Facebook API 文档可能相当模糊。某些话题也很难找到,Facebook 也不断地贬低某些话题。然而,当他们弃用某些东西时,他们往往会给开发人员很大的宽容来更新他们的代码。
祝你好运。
This is a big topic and requires you to dive in the graph API which I assume you've looked at. In case you haven't here is the link
https://graph.facebook.com/
Basically, you need to ask a facebook user for permission to do certain things. What you want to be able to do with their account will be in line with what your application does. When a user accepts these permissions, you will have an access token that you can then use in a query string to query the graph API for any data available about that person (limited by what permissions you asked for from them).
It's then up to your code to interpret that data (JSON or XML) and then display it, interact with it etc.
Be warned, the Facebook API documentation can be quite vague. It is also hard to find certain topics, and Facebook constantly deprecates things. When they deprecate things they do tend to give a good amount of leniency for developers to update their code however.
Best of luck.