views:

266

answers:

2

Hello,

I have a website with a database of users and I would like to allow them to display on their profile page their current tweet message (if they have a Twitter account).

After searching, I had seen this tool: http://juitter.com It seems to be a little bit complex for just my needs.

I am working with Rails. Do you know a tool as simple as possible which can do that?

Thank you D

A: 

Take a look at the twitter gem. It's super simple to use.

John Topley
Thank you John for this gem, I will see it :)
Denis
+3  A: 

You may look at the twitter api: users/show

Example:

$ 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,
...
}

You can get the last tweet with a simple jquery call:

<!DOCTYPE html>
<html>
<head>
    <script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
    <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>
The MYYN
Many thanks! Just a last question: how can I get the id number of a profile? (for instance from: http://twitter.com/yukihiro_matz)
Denis
Look at the page html source. There are a couple of references to the user id, e.g. 'http://twitter.com/statuses/user_timeline/20104013.rss'. I haven't look into this issue in-depth, but i would suggest, that your users either provide their twitter id directly or you scrape the page one time to get the user id and store it locally on your server. That's just a quick reply .. you may find a better way to implement this ..
The MYYN