身份验证后获取Facebook图片

Getting Facebook Picture After Authentication

本文关键字:图片 Facebook 获取 身份验证      更新时间:2023-09-26

我正在尝试在验证用户的Facebook 时自动获取用户的个人资料图片

addFacebookInformationToProfile() {
    if (Meteor.isServer) {
      // This will only merge in information the first time, then ignore it once the flag is true
      const user = Meteor.user();
      let username = slugify(user.services.facebook.name, '');
      let i = 1;
      while (Meteor.users.findOne({username})) {
        username = slugify(user.services.facebook.name, '') + '' + i;
        i++;
      }
      Meteor.users.update({ _id: Meteor.userId(), 'profile.facebook': { $ne:true }}, {
        $set: {
          'profile.email': user.services.facebook.email,
          'profile.name': user.services.facebook.name,
          'username': username,
          'profile.gender': user.services.facebook.gender,
          'profile.facebook': true
        }
      });
    }
  }

我尝试的是

'profile.gender'行我放入

'profile.picture': "http://graph.facebook.com/" + user.services.facebook.id + "/picture/?type=large",运行该行时,图片如下所示:https://www.dropbox.com/s/j4nzmhad4pf6dqb/Screenshot%202016-05-13%2015.53.25.png?dl=0

我也试过'profile.picture': user.services.facebook.picture,

两者都无效,'profile.picture': 之后可能发生的情况

您可以使用获取facebook图片

"https://graph.facebook.com/" + user.services.facebook.id + "/picture?width=200&height=200",