Adding a Drupal Recent Tweets Block

These are the steps I took to add the recent tweets block you see on the right of my blog page.

1. Created a new block with the Title and Block Description, "Recent Tweets."

2. Pasted the following code into the Block Body. I originally found the code here.

  1. <div id="twitter_div">
  2. <ul id="twitter_update_list"></ul></div>
  3. <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
  4. <script text="text/javascript" src="http://twitter.com/statuses/user_timeline/juliakm.json?callback=twitterCallback2&count=2"></script>

Here is what you will need to change:

  1. <div id="twitter_div">
  2. <ul id="twitter_update_list"></ul></div>
  3. <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
  4. <script text="text/javascript" src="http://twitter.com/statuses/user_timeline/[Your Twitter Username].json?callback=twitterCallback2&count=[Number of Posts to Display]"></script>

3. Set the Input format to PHP Code.

4. Cleared the cache on my site using the Devel module.

5. Logged out and admired my block.

Thanks

This was brilliant. Worked Great. Also, for a side note, if you haven't already enabled the php code, you can do so my going to Modules > and finding the php one to enable it. I had to do that before this would work, so just in case anyone else doesn't see php code under input format, that's how it's done.

Check it out on my page: http://www.warep.com

A line missing

You missed the last line that will have the actual user name and json syntax call.

Thanks

Nice, but the original Twitter Javascript is not so optimal. I would prefer to cache tweets to prevent a slowdown of your site when Twitter is down

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.

More information about formatting options