【问题标题】:How to use twitter REST api along with railscast 241如何使用 twitter REST api 和 railscast 241
【发布时间】:2012-11-13 12:19:27
【问题描述】:

这里是 REST 新手:

我正在使用来自 ryan bates rails cast #241 的代码

http://railscasts.com/episodes/241-simple-omniauth

我可以很好地与我的用户进行身份验证....

现在我想显示我在 views/articles/index.html.erb 页面上发布的最后一条推文......

我只想显示来自这个 REST api 的数据...“https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline”

如何以最简单的方式更改此代码?

<% title "Articles" %>

<div id="articles">

    <!-- TODO grab my tweets with GET Statuses/home_timeline -->




<% for article in @articles %>
  <h2>
    <%= link_to article.name, article %>
    <span class="comments">(<%= pluralize(article.comments.size, 'comment') %>)</span>
  </h2>
  <div class="created_at">on <%= article.created_at.strftime('%b %d, %Y') %></div>
  <div class="content"><%= simple_format(article.content) %></div>
<% end %>
</div>

<p><%= link_to "New Article", new_article_path %></p>

感谢您的帮助。

【问题讨论】:

    标签: ruby-on-rails rest twitter


    【解决方案1】:

    你应该在 twitter gem 上抢购:http://sferik.github.com/twitter/

    您可以获取用户的时间线,例如:timeline = Twitter.user_timeline( twitter_username )

    【讨论】:

    • 宾果游戏!我必须创建一个博客教程来帮助自己和他人......我在一年前做过,但忘记了我做了什么:(
    猜你喜欢
    • 1970-01-01
    • 2023-03-27
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-18
    • 2018-10-10
    • 1970-01-01
    相关资源
    最近更新 更多