我一直在尝试从atmosphere.js获取bengott:阿凡达软件包,以便与Facebook合作,但一直未能如愿。当我使用{{> avatar user=this shape="circle"}}时,它似乎只显示一个灰色的圆圈,里面没有图片。
其他调用,如{{currentUser.profile.name}},可以很好地工作。
我怎样才能成功地显示一个头像,无论有没有bengott:avatar包?
发布于 2015-03-19 23:41:25
取而代之的是,你不需要访问令牌或任何特殊的东西来获取他们的头像,只需要他们的facebook用户id。
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
options.profile.picture = "http://graph.facebook.com/" + user.services.facebook.id + "/picture/?type=large";
user.profile = options.profile;
}
return user;
});发布于 2015-03-20 22:20:00
我使用一个基于用户Facebook ID的助手函数来获取服务器上的图像。希望这能有所帮助。
userPicHelper: function() {
if (this.profile) {
var id = this.profile.facebookId;
var img = 'http://graph.facebook.com/' + id + '/picture?type=square&height=160&width=160';
return img;
}
},在模板中,您可以像这样使用辅助对象:
<img src="{{userPicHelper}}" alt="" />https://stackoverflow.com/questions/29148854
复制相似问题