<strong>IMPORTANT:</strong> a commenter recently led me to find a problem with the plugin, whereby setup.php enters an incorrect location for the get_tweets.php file. This will be fixed with a new release soon, but in the meantime you can ammend the js yourself, or if you contact me I will make the change and send you a revised file. As always any problems just comment and I will reply.
TweetSlider is a jQuery Plugin that pulls in Tweets for a given username or hashtag (as of 2.5 for hashtags) and displays them in a horizontal slider. Full details on how the plugin can be configured using options are found below.
*NEW FEATURE* PHP Caching: The Plugin now calls get_tweets.php which is part of the package. It should be added to the same directory as all other files. PHP also must be able to write this folder as it creates the directory and files for caching. This also fixes the issue raised on Git by lmorgan69a, which was reported as ie9 crashing, but was actually the auto-refresh (see below) failing to bring in new tweets because the Twitter API limit had been reached. This only happened when the auto-refresh delay was set to short and making more than 150 requests to API per hour. Now the plugin’s PHP caching feature keeps a cache and counts requests, if/when the limit is reached, or if the API request fails for any reason it uses the cached tweets.
IMPORTANT: The plugin now calls a local url for the tweets, it’s default is ‘/tweetslider/get_tweets.php’ meaning that if you upload the plugin directory to the web root it is good to go. If not you can set the correct path manually by editing jquery.tweetslider.min.js (search options.url) or navigate to the setup.php file in the plugin folder in your browser, which will change the url for you.
NOTE: I have built my own system for counting requests, then I realised that the number of requests left before hitting the limit is sent back from Twitter in the Header of the response. And that Twitter also sends a 420 response code when the limit is reached. V3.1 will soon be released getting rid of its own counter, and using one or both of the above methods to prevent problems with rate limiting.
View the full versioning history at the repository on Github: TweetSlider on GitHub
- Added the use of Twitter Entities API on urls so that links appear they are on Twitter as requested by users
- Added option to pull tweets for a search or a username, see below for full details on using this. Also adds support for user_mentions and hashtag entities as well as urls added in previous update.
- Changed stylesheet to remove underline in links
- Fixed incorrect link to js file in example.html
- Auto-Refresh: Goes back for more tweets at a configurable interval.
- Manual Slide: buttons to slide tweets manually
Auto-Refresh: Tweet Slider refreshes the tweets asynchronously (without reloading the page) every 10 minutes (the time can be changed by the user, but this will be covered in the options section).
Manual Slide: V2.1 added next and previous buttons to manually slide the tweets.
|Option Name||Description||Default Value:|
|hash||A hashtag search term without the # symbol|
|username||Name of the Twitter user who’s tweet’s to display. Defaults to blank as hashtag is the default option. If username option is given it overrides use of hashtags and pulls tweets for given user||‘Twitter’|
|slides||Number of Tweets to display||5|
|width||Width of slider||500|
|speed||Speed of sliding animation, ‘slow’,’medium’,’fast’, or milliseconds duration||‘fast’|
|refreshTime||Time between calls to the Twitter API to refresh tweets in milliseconds. 600000 = 10 mins||600000|
Simply download the tweetslider plugin as a .zip file, extract all files, and upload the entire tweetslider folder onto your web server, reference the stylesheet style.css like so (assumes directory added to Web Root):
<link rel="stylesheet" href="/tweetslider/style.css" />
and reference the jquery.tweetslider.min.js folder in a script tag like so:
Both examples above assume the plugin folder is in the web root. If you don’t put it in the web root then obviously these paths will change. You will also need to change the url the plugin calls to get the tweets. The easiest way to do this is to navigate to the setup.php script in the plugin directory in your web browser. It will do the work for you. If you want you can edit jquery.tweetslider.min.js, search options.url and change the value from /tweetslider/get_tweets.php to whatever the correct value is.
Then create a holder for the slider, I have chosen a div with the id tweets.
And call it like so
<!--Tweets of a given user//-->
<!-- Or for a hashtag search //-->
Of course adding any other options you want with comma delimeters. And that is it. I hope you enjoy using Tweetslider V2.5.
Example: Tweets for a Given User (@dubnalife – see comments, user encountered problems and so I changed the example to use his username):
***NOTE***To all the people having trouble setting the width, it is one of the plugin options, see below I have set the width to 300px
As you will see if you look at the source code I have added the new Tweetslider to the head of this site and put in the following example:
Note: it is very important that you don’t enclose the width value in quotes or the value will be sent as a string not a number, which breaks the plugin.
It Looks Like This:
example1 Display tweets for the user @Twitter