如何在Meteor上获得某人的Twitter个人资料图片?

如何在Meteor上获得某人的Twitter个人资料图片?,twitter,meteor,Twitter,Meteor,我正在用Meteor做一个项目。人们可以使用Twitter登录。我想知道是否有办法在Accounts.onCreateUser中从Twitter获取某人的个人资料图片。以下是我所拥有的: Accounts.onCreateUser(function(options, user) { var twitterInfo = user.services.twitter; if (options.profile){ options.profile.createdAt =

我正在用Meteor做一个项目。人们可以使用Twitter登录。我想知道是否有办法在Accounts.onCreateUser中从Twitter获取某人的个人资料图片。以下是我所拥有的:

Accounts.onCreateUser(function(options, user) {

   var twitterInfo =  user.services.twitter;

   if (options.profile){

        options.profile.createdAt = new Date();//now!
        options.profile.twitterId = twitterInfo.id;
        options.profile.username = twitterInfo.screenName;
        options.profile.name  = options.profile.name;
        user.profile = options.profile; 
   }

    return user;
}); 
谢谢

根据API()添加以下内容:

options.profile.display_picture="http://api.twitter.com/1/users/profile_image/"+twitterInfo.screenName;
这是传统的方法,在API1.1中稍微困难一些():


当用户在
services.twitter.profile\u image\u url和
services.twitter.profile\u url的用户集合中设置配置文件pic的twitter url时,您需要获取
get users/show
并解析
profile\u image\u url的
对象读出那些网址

我使用以下行在profile对象中设置一个users twitter profile pic,默认情况下客户端可见:

Meteor.users.update({_id:Meteor.userId()}, {$set {"profile.twitterpic":user.services.twitter.profile_image_url}});

使用twitter api 1.0不推荐。被接受的答案不再有效

Meteor.user().services.twitter.profile_image_url 

为我工作

我已经将Meteor软件包帐户ui帐户twitter添加到我的应用程序中。 这些软件包非常容易地添加了Twitter OAuth登录功能

更好的是:我可以从任何地方通过
Meteor.user()
访问当前用户。 更好的是,它们是自己的模板。所以我可以用
{{services.twitter.screenName}
在我的应用程序中的任意位置获取用户的twitter句柄。
{{services.twitter.profile_image_url}}
用于头像图像url。和
Twitter用户名的
{{profile.name}}

API1.0已被弃用,不再可用。我还提到了如何使用1.1,您需要从用户对象中获取
/users/show
并获取
profile\u image\u url
。您需要首先使用OAuth并使用令牌发出请求