如何从Node.js访问Facebook用户数据? [英] How to access Facebook user data from Node.js?

查看:179
本文介绍了如何从Node.js访问Facebook用户数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Facebook应用程序的PHP应用程序。用户登录到它,提供权限,然后我需要我的后台Node.js来获取有关此用户的一些数据。这是一个奇怪的流程,但有一个原因。技术上所有Node.js对于用户当前所了解的都是Facebook用户ID。
需要知道什么才能获取有关此用户的信息(假设用户仅使用PHP进行身份验证,因此PHP可以为我提供此数据)。那么最好使用的Node.js库是什么?

解决方案

我非常怀疑有一个Node.js库Facebook还没有话虽如此,很容易拉这样的数据。所有你真正需要的是access_token从PHP,然后只需点击:

  https://graph.facebook.com/USER_NAME_OR_ID? access_token = ACCESS_TOKEN 

这将给你一堆关于用户的信息,或至少你所拥有的获得许可请注意,您需要运行Node> = 0.4才能使用https。



或者您只需要基本数据(几乎只是名称/性别),点击:

  http://graph.facebook.com/USER_NAME_OR_ID 


I have PHP app which is a Facebook app. User logs in to it, gives permissions, and then I need my backend Node.js to get some data about this user. It's a weird flow, but there is a reason for that. Technically all what Node.js knows about user currently is Facebook user id. What esle does it need to know to be able to fetch info about this user (assuming that user just authenticated with PHP part, so PHP can supply me this data). And what's the best Node.js library to use for that?

解决方案

I seriously doubt that there is a Node.js library for Facebook yet. That being said, it's very easy to pull data like this. All you really need is the access_token from PHP, then just hit:

https://graph.facebook.com/USER_NAME_OR_ID?access_token=ACCESS_TOKEN

which will give you a bunch of info about the user, or at least whatever you have permission to get. Note that you'll need to be running Node >= 0.4 in order to use https.

or if you just want basic data (pretty much just name/gender), hit:

http://graph.facebook.com/USER_NAME_OR_ID

这篇关于如何从Node.js访问Facebook用户数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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