How to query a Facebook user picture via Meteor's accounts-facebook?

前端 未结 2 794
一向
一向 2020-12-25 07:48

I\'m trying to get the authenticated Facebook user\'s profile picture, to use within a Meteor application. I\'ve tried the following

Meteor.publish(\"facebo         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 08:42

    if you want to get picture for facebook

    Accounts.onCreateUser(function(options, user) {
        if (typeof(user.services.facebook) != "undefined") {
            user.services.facebook.picture = "http://graph.facebook.com/" + user.services.facebook.id + "/picture/?type=large";
        }
        return user;
    });
    

    you can to add this helper function

    UI.registerHelper("getImageUser", function (userId) {
        var user= Meteor.users.findOne(userId);
        if (user.services)
        {
            if (user.services.facebook)
                return user.services.facebook.picture;
            if (user.services.twitter)
                return user.services.twitter.profile_image_url;
            if (user.services.google)
                return user.services.google.picture;
        }
        else
        {
            return "images/withOutPhoto.png";
        }
    });
    

    in your html

    ...
    

提交回复
热议问题