meteor不能访问个人资料图片
我是新来的meteor,我试图得到当前login用户的照片。
我尝试了很多方法,但是这个感觉就像应该工作:
这是在索引的js:
Template.user_loggedout.events({ "click #login" : function(e, t){ Meteor.loginWithFacebook({ }) } })
所以它基本上只是用facebooklogin。 authentication到此为止是成功的。 现在在服务器端,我创build用户时尝试了很多方法来获取图片,但是这个看起来是最干净和最简单的:
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; });
我也尝试过谷歌(完全实施谷歌login):
user.profile.profile_picture = user.services.google.picture;
在我看来,我只是这么称呼它:
<img src="currentUser.profile.picture"
事情是不pipe我尝试哪种方式,我打电话给这个破碎的链接图像:
我敢肯定,我是一个明显的举措,但我真的不知道我的电话有什么问题。 难道我做错了什么?
您应该将辅助函件放在双花括号{{helper}}中。 否则它会认为它是一个纯文本。
<img scr="{{currentUser.profile.picture}}" alt="{{currentUser.username}}">
删除最后的if(options.profile)
Accounts.onCreateUser(function(options, user) { options.profile.picture = "http://graph.facebook.com/" + user.services.facebook.id + "/picture/?type=large"; user.profile = options.profile; return user; });
然后在你的模板中
{{#if currentUser}} <img scr="{{currentUser.profile.picture}}" alt="{{currentUser.username}}"> {{/if}}
- validationFacebook X-Hub-Signature
- 在Rest API中使用Facebook维护Express和NodeJS中的JWT的密钥和访问令牌
- 在GraphQL中将数组作为parameter passing
- passportjs + facebook +当前用户
- 从节点js调用另一个文件
- Fb开发者问题 – 'URL无法validation。 响应不符合预期的挑战'
- 使用Passport和OAuth2 +社交networking的NodeJS REST身份validation
- 如何在没有会话的Facebook Passport之后redirect到之前的URL
- Facebook chatbot和身份validation