开发者

How can I get tweets using Jquery?

I need to display new tweets from Twitter using J开发者_运维百科query.


jquery.tweet.js is an excellent plugin to use.

It is really simple to get up and running, just download the associated files and add the following to your html (with the js ideally in an external file of course!)

<script type='text/javascript'>
    $(document).ready(function(){
        $(".tweet").tweet({
            username: "seaofclouds",
            join_text: "auto",
            avatar_size: 32,
            count: 3,
            auto_join_text_default: "we said,", 
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "loading tweets..."
        });
    });
</script>
<div class="tweet"></div>

It comes with some predefined styles but is easy enough to add your own styles.

The html output is an unordered list with different classes for even and odd items, for example:

<ul class="tweet_list">
 <li class="tweet_first tweet_odd"> 
  <span class="tweet_text">[Tweet text]</span>
  <span class="tweet_time">about 21 hours ago</span>
 </li>
 <li class="tweet_even">
  <span class="tweet_text">[Tweet text]</span>
  <span class="tweet_time">about 22 hours ago</span>
 </li>
</ul>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜