Garee’s Twitter Stream

Garee’s Twitter Stream is a highly customizable WordPress-plugin that shows either tweets of a twitter user, his favorites, a user’s list or a twitter-search.

The output is generated from template-files or your own templates, which you can write with Mustache.

Main-advantages:

  • No javascript/ajax – only server-side scripting
  • Tweet-requests are cached
  • CSS only included if shortcode found on page
  • highly customizable with Mustache-templates

Version 1.0 | Live-Demo | Download from WordPress

Usage

Just insert the following shortcode anywhere in your blog (for use in a widget: use the text-widget and insert the shortcode there)

[twitter_stream user="your_twitter_account"]

Attributes

Here’s a list of all attributes the shortcode accepts. Additional attributes may be available depending on the chosen template

template
a predefined template consisting of a html- and optionally a css-file in the subdirectory "templates" of the plugin-folder. If left blank the template ‘default’ is chosen.
If the template-attribute is missing you have to define a template yourself (*). This can be done using the following enclosing shortcut:
[twitter_stream_template]*[/twitter_stream_template]
Check out the examples below to see how to define your own template.
user
If you would like the plugin to display the tweets of a certain user, set "user" to this twitter-user. This option cannot be combined with any of the following options: "list", "favorites", "search"
list
If you would like the plugin to display the tweets from certain user’s list, set "list" to "user/list". This option cannot be combined with any of the following options: "user", "favorites", "search"
favorites
If you would like the plugin to display the favorite tweets of a certain user, set "favorites" to this twitter-user. This option cannot be combined with any of the following options: "user", "list", "search"
search
If you would like the plugin to display the results of a twitter-search, enter any search-term as option "search". This option cannot be combined with any of the following options: "user", "list", "favorites"
geocode
Limit your search to a specific area. "geocode" has to be of the form "lat,lon,radius" (eg. "53.273,-7.494,50mi"). Can be combined with "search", but not with "user", "list" or "favorites" (v0.6+)
since_id
Returns results with an ID greater than (that is, newer than) or equal to the specified ID. (v0.9+)
max_id
Returns results with an ID less than (that is, older than) or equal to the specified ID. (Doesn’t work for search-option. Use ‘until’ instead.) (v0.9+)
until
Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. (Only works for the search-option. Use ‘max_id’ instead.) (v0.9+)
count
Specify how many tweets should be displayed. The default-value is 10.
lang
Restricts tweets to the given language, given by an ISO 639-1 code.
result_type
Specifies what type of search results you would prefer to receive. The current default is "mixed." Valid values include: "mixed", "recent" and "popular"
inlcude_rts
Set to true, t or 1 to inlcude retweets.
exclude_replies
Set to true, t or 1 to exclude replies.
cache_time
Specify how long the tweets should be cached (in minutes). The default cache-time is 15 minutes. (a low value may result in rate limit exceeding and no answers from twitter.com!)
date_format
Choose the format for the Mustache-tag {{tweet_date_formatted}}. For more information check out the syntax of PHP-Date-function‘s format-parameter.
new_window
Set to true, t or 1 to open any links in the tweet in a new window. (v1.0+)

Template-Files

A couple of templates come with the plugin. You can write and install additional templates yourself. A template consists of a html-file with the Mustache-template and (optionally) a css-file with the same filename as the html-file. If your css-code has images and javascript-files, put them in a subfolder of the templates-folder named after your template. Then upload all files via FTP and insert the shortcode for your template. If you define your template directly in the shortcode, you cannot link to a additional css-file. Of course you can include css-styling directly into the html-code of your template.

Mustache-Templates

The following components can be used to build your own html-template. Additional components can be generated by inserting custom attributes in the shortcode. The components are only available in the html-template, not in the css-file! Check out the template-files in the plugin to see how it’s still possible to change css-values with custom attributes from your shortcode. For more infos about Mustache-syntax check out the PHP-implementation and the manuals on http://mustache.github.com/

{{user_screen_name}}
screen name of the user who posted the tweet
{{user_name}}
full name of the user who posted the tweet
{{{user}}}
the user’s screen name linked to his twitter-profile. Generated using the following template: <a class="tweet_user" href="{{user_url}}">{{user_screen_name}}</a>
{{avatar_url}}
url of the user’s profile-image
{{{avatar}}}
the user’s profile-image linked to the tweet. Generated using the following template: <a class="tweet_avatar" href="{{user_url}}"><img src="{{avatar_url}}" alt="{{user_screen_name}}’s avatar" title="{{user_screen_name}}’s avatar" border="0"/></a>
{{tweet_text_raw}}
tweet text plain, no links
{{{tweet_text}}}
tweet text including links to twitter-tags and -users and any other links made clickable
{{tweet_is_retweet}}
true if tweet is a retweet
{{retweeted_by_screen_name}}
if tweet is a retweet: screen name of the user that retweeted
{{retweeted_by_name}}
if tweet is a retweet: full name of the user that retweeted
{{{tweet_source}}}
source of the tweet with clickable links
{{tweet_time_raw}}
tweet time
{{tweet_time_formatted}}
tweet time (formatted with the date_format-option or automatically if option missing)
{{tweet_time_relative}}
relative tweet time (e.g. 5 min ago)
{{{tweet_time}}}
relative tweet time linked to the tweet. Generated using the following template: <span class="tweet_time"><a href="{{tweet_url}}" title="view tweet on twitter">{{tweet_time_relative}}</a>
{{tweet_has_image}}
true if the tweet contains an image
{{tweet_image_url}}
the url which leads to the twitter-page that shows the image. (short form)
{{tweet_image_expanded_url}}
the url which leads to the twitter-page that shows the image. (expanded form)
{{tweet_image_media_url}}
the url of the image (twitter offers 4 sizes: "thumb", "small", "medium", "large". For the large image use "{{tweet_image_url}}:large". Also check out the template "images".
{{tweet_image_display_url}}
shortended url to display as link to the image
{{{tweet_image_link}}}
text-link to the image on twitter.com. Generated using the following template: <a href="{{tweet_image_url}}" class="tweet_action tweet_show_image" target="_blank">{{tweet_image_display_url}}</a>
{{{tweet_image}}}
tweet_image as thumbnail linked to the image on twitter.com. Generated using the following template: <a href="{{tweet_image_url}}" target="_blank"><img src="{{tweet_image_media_url}}:thumb" title="{{tweet_text_raw}}" alt="{{tweet_text_raw}}" class="tweet_image" /></a>
{{tweet_url}}
url to the tweet on twitter.com.
{{reply_url}}
url to reply to the current tweet.
{{retweet_url}}
url to retweet the current tweet.
{{favorite_url}}
url to add the current tweet to favorites.
{{{reply_action}}}
link to reply to the current tweet. Generated using the following template: <a class="tweet_action tweet_reply" href="{{reply_url}}">reply</a>
{{{retweet_action}}}
link to retweet the current tweet. Generated using the following template: <a class="tweet_action tweet_retweet" href="{{retweet_url}}">retweet</a>
{{{favorite_action}}}
link to add the current tweet to favorites. Generated using the following template: <a class="tweet_action tweet_favorite" href="{{favorite_url}}">favorite</a>
{{template_dir}}
url of the template-directory. Can be used to get access to the template’s image-files from the html-template

Moreover any shortcode-option is available as mustache-tag. E.g. if you make a twitter-search and set a value for “search” then you can use {{search}} in your template.

quot;, ddddlt;a class=

39 Responses to “Garee’s Twitter Stream”


  • thanks for this great plugin. Is it possible to display only tweets that come from a specific source and that have a specific hashtag?

  • Great job Gary. However I'm dead in the water. I need to combine user and search

    I am trying to capture the results of this twitter search: https://twitter.com/search?q=%23mp125%20OR%20%23FNL%20from%3Atim_archambault&src=typd

    basically: #mp125 #FNL from:tim_archambault

    Is there any workaround for this? Thank you.

  • Any plans for porting the plugin to API 1.1?

  • Hi Garee,
    your plugin is great, but I had to work on it to make it up working, since I had to see the ID numeber of my twitter account ;) , and then especially how to integrate it with the tamplate's php and css codes. However, thank you so much because I was looking for something like that for a while. Good Job

  • I dig the plug-in, but sometimes it works and sometimes it doesn't. I'm totally confused. This is the error I'm getting– "Fatal error: Cannot use string offset as an array in ../wp-content/plugins/garees-twitter-stream/garees_twitter_stream.php on line 265."

    Can anyone help?

    -George

  • Hi
    I am having an issue on my mobile that I get this error
    Safari cannot open the page because too many redirects occured.

    Do you have nay idea why this is occuring and a possible fix?

    Thanks

    • Don't worry – WPtouch was causing the issue the homepage was redirecting on itself and this only became apparent once your plugin was installed.

      • Posted on You're a far braver vweeir than I I've given up on even the one genre show this season I sorta liked, Reaper, cause when it's on, I can't motivate enough interest to actually watch a whole episode.I'm a reality whore now. It's all I do.

  • Hmmm. No responses since February 8. Another nice plugin abandoned by its creator?

  • Hi Garee,

    Amazing work –

    It looks like if I want images to display I can only display tweets with images. Is there a way to display both tweets with images and without?

  • This plugin is great!
    Just one doubt: this morning I opened my site (without making any change from yesterday) and the plugin was not working. I've checked and deleting the hastag exclude_replies="true" it works.Till yesterday it was working perfectly with it. Any idea?

  • Hi Garee,

    Is there a way to exclude a Twitter ID from the stream? I have a search function running & the competing sight keeps hijacking the stream with ads.

    http://www.foodtrailersaustin.com/sxswtrailer-food-trailer-roundup/

  • Can your tell me how to use Garee’s Twitter Stream below the header but above my posts? I'm not sure what to add or to what file.

    I just moved back to WordPress from Blogger. You can see what I have in mind at <a href="http://www.theluckyladybug.net/">my old location</a>. I appreciate your help!

    Thank you!

  • Hi, your plug-in is interesting but I got this error : "Garee's Twitter Stream Error : Rate limit exceeded! (check your cache-time-setting)". I tried with other users account and it works perfectly but not with me. So I think the problem come from my twitter account. What do I need to do to solve this error, please ?

  • Hey Sebastian – thanks for the great plugin.

    One question; is there anyway of having tweets of multiple users displayed? I'm using this for a book site and was pulling in tweets of a book's author — but in some cases there might be two authors, so was hoping there'd be a way of sending in user="one,two" and getting the tweets of both authors?

    • Hi Garry
      Unfortunately that's not possible with the plugin. My plugin gets its content from twitter's api and therefore can get only one user's timeline at a time. In order to have multiple users, the plugin would have to send multiple requests to twitter and then combine and sort the results, which is by far more complex than what it is doing right now.
      Maybe with a custom template, which would be easier to build, you could show two user's tweets side by side.

  • It doesn't work for me. I get
    Warning: Invalid argument supplied for foreach() in /www/clanteam.com/a/n/t/antistress/htdocs/wp-content/plugins/garees-twitter-stream/garees_twitter_stream.php</b> on line 258

    • Hi. That usually happens if the twitter-search doesn't return any tweets. Maybe you'll have to change the shortcode. If that doesn't work it's possible that your webhoster doesn't allow connections to other domains via PHP. Then my plugin will fail completely, because the tweets are downloaded to the server and then shown to the user.
      But as I can see on your website, it seems you've found a solution for displaying tweets.

    • Anna Posted on Wish I could have gone with you guys. I always want to look back at Hunter and then I alosmt fall over. Typical me LOVE these pictures of the ride.

  • Hi garee,

    I just want to point out that if the shortcode has an attribute with value in DOUBLEQUOTES set BEFORE the template attribute ( [twitter_stream user="someuser" template="garee"] ) the CSS-File for this template will not load!
    This is because first part of the RegEx in garees_twitter_stream.php line 406 doesn't consider doublequotes. I just added \" in the first character class and now it works fine.

    Thanks for this great plugin.
    - Jay

  • Hello ,

    I use this awesome plugin in my website egypttweeps.com , In fact it is all my website :)

    However , I'd like to know the code I should use to show tweets from a HashTag not a user ….

    Is this available

    [twitter_stream template="embed" hashtag="#somehashtag" count=10]

    something like that

    • Hi
      Yes you can do that. Just use the search-option:

      [twitter_stream search="#somehashtag" count=10]

      btw: in version 0.9 the embed-template is the default-template. You can drop the template-option.

      • mmmm… I'v a new problem garee about the images
        [twitter_stream template="images" user="garee76" count=100]
        this show each image in a line not 3 in raw like in the demo

        see it here http://egypttweeps.com/images/

        • That's a problem of the template. Your template probably doesn't use definition-lists for the html-output of galleries. So the css for the output of the images-template is missing. The image-template uses html-definition list for displaying the images itself. But you can change the template. For instance if you delete all dl- and dd-tags. The images will be put just one after the other and you'll have as many rows as fit.

  • Hi… love the plugin… I am trying to open the links (URL shortener) from the twitter in a new page not in the same page as my site. Is there an easy way to get it to work?

    • Hi Cris
      That's a good point you mention. I just published version 1.0 of the plugin which has a new shortcode-option "new_window". If set to "true", "t" or 1, all links (twitter-users, hashtags and shortened links) will be opened in a new window.

  • Hi,
    Just updated to version .9 and it doesn't get along with my Gantry, Rocket Themed site. I don't have time to fully diagnose the problem right now, can you show me where I could obtain version .8 again, I failed to archive it and I was unable to find it in the repository.

    Thanks!

    • Hi Ryan
      I think the problem is, that in version 0.9 the default-template changed. So if you didn't have the option 'template' in your shortcode, you'll have to insert 'template="list"'. And if you had 'template="embed"' you can take the template-option away. Sorry for the inconvenience.

      If that doens't work you'll find version 0.8 here:
      http://plugins.trac.wordpress.org/browser/garees-twitter-stream/trunk?rev=476171

  • Hi Garee –

    I'm admin of @TweetweekUSA and TweetweekUSA.com. It's a #LocationCuration project taking inspiration from @Sweden and CuratorsofSweden.com.

    Each week a new US citizen or resident tweets from @TweetweekUSA with their own unique POV and voice. I would like to present on TweetweekUSA.com an archive of each curator's tweets that starts with their first (specific date & time) and ends with their last (specific date & time). Would thin be possible with Garee's Twitter Stream?

    Or maybe it would be easier with parsing the timeline archive by avatar images rather than date ranges.

    I'm looking forward to hearing from you.

    – Nelson Bonner

    • Hi Nelson
      With version 0.9 – just released in this minute – that would actually be possible. The new version has 3 new shortcode-options that can narrow the tweets to display to a time-frame. Unfortunately this isn't done by entering a date, but rather be specifying tweet-ids. So what you'd have to do is find the curator's first and last tweets, get their ids, and enter them in the shortcode. This way all the tweets between these two tweets will be displayed:

      [twitter_stream user="TweetweekUSA" since_id=162674257535569920 max_id=162683874848161792 count=100]
  • Hi from earthquake-report.com, a non-profit organization. I found the ideal solution for showing the many earthquakes in the world as a per country page.
    As i have a twitter account per country, it would have been great to stream the twitter into my wordpress site.
    But … i am always getting the following error : Garee's Twitter Stream Error : Rate limit exceeded! (check your cache-time-setting) Did set the cache already to 30 minutes. I guess this will be coming back all the time in my case , as i have 40 more page or 40 more pages to do !

    Armand

    • Hi Armand
      The problem is probably twitter's rate limit. As Garee's Twitter Stream is a server-scripted solution, your webhost's server connects to twitter.com to get the tweets. They are then integrated in the site and sent to the user. So, if twitter.com sees too many requests from your server-IP, it will deny them and show an error-message. So maybe other websites or services share the same IP and connect to twitter.com…

      It's possible to get tweets displayed with javascript. Then the user's browser makes the connection to twitter.com. An example is "seaoflouds tweet!" which is also available as a wordpress-plugin.

      Since my plugin doesn't yet support authentication, there's no way to get around twitter's rate limits :-(
      Authentication may come in a future version, but I can't tell you how long it will take.

  • Works perfectly.
    But (always there is one), I use Thesis and indeed the widgets are a wee bit too small.
    I wanted it in the multimediabox.., so after a bit of a search I added a function in custom_functions.php and disco.
    So.., the update was a succes.., it works…

    thanks…

  • Pfew… not my fault…
    I'll check the update and work it out. Will leave a respons here…

    Thanks…

  • Hey.., love the plugin, at least the demo.
    I put the code in a widget., sadly, it doesn't work.
    I did put the code on a page and it worked nicely.., sooo… I don't know.., could be me.
    I'll leave the widget active so you can see…
    Love to know what I do wrong…

    /Rogier

    • Hi Rogier
      Not your fault! Some templates don't run shortcodes in the text-widget. I just submitted version 0.8 of the plugin to wordpress with a fix that enforces wordpress to run shortcodes in the text-widget. Get the update and it should run fine… Though maybe you will have to use a smaller template (e.g. minimal) in the sidebar. I'm not sure the embedded tweets will fit!

Leave a Reply

*

If you like Garee's Twitter Stream plugin, you can buy me a coffee!

Flattr this
or