这是我在 node.js 中的第一步,尤其是在护照中,我遇到了一个非常烦人的问题。我正在尝试让用户使用他的 Facebook 个人资料参加的活动,但无论我尝试什么,它都不起作用。所以我想“好吧,让我们获取其他数据”,但除了基本的显示名称和个人资料图片之外,任何其他尝试(生日、事件、朋友列表等)最终都没有数据。我在过去几天(第一次)尝试了很多使用 Facebook 的 api 并且根本无法弄清楚......这是我最后一次尝试:
passport.use(new FacebookStrategy({
clientID: config.fb.appID,
clientSecret: config.fb.appSecret,
callbackURL: config.fb.callbackURL,
profileFields: ['id', 'displayName', 'photos', 'birthday', 'events', 'profileUrl', 'emails', 'likes']
}, function(accessToken, refershToken, profile, done){
//Check if the user exists in our Mongo DB database
//if not, create one and return the profile
//if exists, return profile
userModel.findOne({'profileID':profile.id}, function(err, result){
if(result){
done(null,result);
} else {
// Create a new user in our mongoLab account
var newFbUSer = new userModel({
profileID: profile.id,
fullname: profile.displayName,
profilePic:profile.photos[0].value || '',
birthday:profile.birthday,
//friends:profile.user.friends[0],
profileUrl:profile.profileUrl
});
newFbUSer.save(function(err){
done(null,newFbUSer);
console.log(newFbUSer.displayName);
})
}
})
}))
关于如何获取和使用用户的朋友列表/事件的任何帮助?