【问题标题】:Meteor: Fetching Data From Account-Twitter Mongo CollectionMeteor:从账户中获取数据-Twitter Mongo 合集
【发布时间】:2015-03-04 11:52:41
【问题描述】:

我正在尝试显示 accounts-twitter 包中的一些数据。我需要来自 Twitter 的用户个人资料图片、用户名和姓名。我已经使用meteor mongo 进行了检查,以查看该数据是否存在。 Profile.html 是我为此存储模板的地方:

<template name="profile">
    <div class="col s4">
    <div class="z-depth-2">
      <div class="card blue-grey darken-1">
        <div class="card-content white-text">
          <img class="circle-profile center-align" src="{{services.twitter.profile_image_url}}" style="border-radius: 50%" width="50px" height="50px"/>
          <br>
          <span class="card-title">{{profile.name}}</span>
        </div>
        <div class="card-action">
          <a href="http://twitter.com/{{services.twitter.screenName}}">View Profile</a>
        </div>
      </div>
    </div>
    </div>
</template>

<template name="display">
  {{#each users}}
    {{> profile}}
  {{/each}}
</template>

我还有 profile.js,它使用帮助器从集合中获取数据:

Template.display.helpers({
  users: function() {
    return Mongo.users.find();
  }
});

当我查看我的主要区域时,我的收藏中的个人资料没有显示。请指教。提前致谢!

【问题讨论】:

    标签: mongodb twitter meteor user-accounts


    【解决方案1】:

    来自docs

    配置文件默认发布,并且只能由当前用户更新。存储 Twitter 信息的服务并不是因为它包含身份验证令牌,所以这将是一个安全问题。最有效的方法可能是在 onCreateUser() 方法中将这些值复制到配置文件中以便发布。

    您也可以仅从服务中发布您需要的那些字段,但我个人喜欢将其分开,因为它包含敏感信息。

    【讨论】:

    • 谢谢!我刚刚从 Twitter 发布了我需要的个人资料图片、用户名和姓名字段。
    猜你喜欢
    • 1970-01-01
    • 2015-11-17
    • 1970-01-01
    • 2014-11-12
    • 2014-12-01
    • 2018-02-12
    • 2013-12-11
    • 2016-09-15
    • 2017-05-15
    相关资源
    最近更新 更多