ruby-on-rails - 分享网页上的最后一条推文

标签 ruby-on-rails twitter

我有一个包含用户数据库的网站,我希望允许他们在个人资料页面上显示他们当前的推文消息(如果他们有 Twitter 帐户)。

经过搜索,我看到了这个工具:http://juitter.com 对于我的需求来说,它似乎有点复杂。

我正在使用 Rails。您知道有一个尽可能简单的工具可以做到这一点吗?

谢谢 d

最佳答案

您可以查看twitter api:users/show

示例:

$ curl http://twitter.com/users/show/20536157.json
{"notifications":false,"time_zone":"Pacific Time (US &
Canada)","friends_count":214,
"profile_sidebar_border_color":"bbccff","url":"http://www.google.com/support/",
"description":"News and updates from Google","status":{"created_at":"Mon Jan
11 19:38:40 +0000
2010","source":"web","truncated":false,"favorited":false,
"in_reply_to_user_id":null,
"in_reply_to_status_id":null,"in_reply_to_screen_name":null,"id":7640306427,

"text":"If
you're interested in what's happening with @google in Sub-Saharan Africa,
check out the new @googleafrica for news &
info."},

"geo_enabled":false,"favourites_count":73, "created_at":"Tue Feb 10
19:14:39 +0000 2009","profile_text_color":"000000","verified":false,
...
}

您可以通过简单的 jquery 调用获取最后一条推文:

<!DOCTYPE html>
<html>
<head>
    <script src="http://www.google.com/jsapi"></script>
    <script>google.load("jquery", "1");</script>
    <script type="text/javascript" charset="utf-8">
        $(document).ready(function(){
            $.getJSON("http://twitter.com/users/show/20536157.json",
                function(data){ $("#tweet").text(data.status.text); });
        });
    </script>
</head>
<body>
    <div id="tweet"><!-- last status will show up here --></div>
</body>
</html>

关于ruby-on-rails - 分享网页上的最后一条推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2048253/

相关文章:

ios - 崩溃 : com. twitter.crashlytics.ios.work-queue

php - 通过 twitter iframe 拦截对 twitter 按钮的点击,以通过 jquery 进行内部计数器

c# - 带有 asp.net web 表单的 Twitter Bootstrap

ruby-on-rails - rails 4 : Skip callback

ruby-on-rails - rails : each in random order

ruby-on-rails - 不确定在哪里(模型或 Controller )定义我的查找方法

ruby-on-rails - CentOS + Rails + nginx + Unicorn + MySQL + RVM(?) 方法?

php - 使用 curl 从 Twitter 流 API 检索数据时写入文件的数据不完整

java - Twitter 用户中的default_profile_image

ruby-on-rails - Guard 不会根据 spec/features/login_spec.rb 上的更改运行