WordPress Plugin: Twitter Stream
It’s been just over a year now since I released my first plugin which you may all know is The Attached Image, so I thought it was time I released another plugin. I hadn’t actually gone out on purpose to make this plugin, but a client’s website needed a simple Twitter feed plugin & while there are already WordPress plugins out there that do the job they insisted a custom one be built. So I set about making it & rather than have it sit in my WordPress functions folder doing nothing (other than working on the client’s site, of course) I thought I should release it as a plugin for anyone to use. 🙂
Latest Info – 04/03/2013
If you have updated the plugin to version 2.5 and are having trouble, please make sure to delete the cache. Either manually or using the button on the options page.
What is Twitter Stream?
Twitter Stream is a very simple plugin originally created as a small function for a client’s website. Rather than have it sit doing nothing in my WordPress functions folder I thought I would extend it and make it into a plugin for everyone to use.
It’s functionality is very, very simple. It is designed to simply grab a set amount of status updates from the Twitter user account you request. If there are enough requests I may add some additional features, but for now it is designed to be very simple and run as quickly as possible while using the least amount of resources possible.
What Features Are There?
- Connect to Twitter securely using oAuth. (required)
- Show the twitter timeline for any public username.
- Choose how many tweets to show.
- A Widget or template function is available.
- File caching to stop API overuse.
- Optional date shown in xx ago format, also links to permalink for the tweet. (Requested by Ron)
- Customizeable via CSS. (see the ‘Can I Style It?’ section below)
- Authentication for better API limiting & ability for protected users to show their tweets.
- @replies now link to the user profile of the user you are replying to.
- #tags now link to the Twitter search page for that hash tag.
- Link to user’s profile, customizable via CSS & via function parameter.
- Follower count can now be shown.
- Retweets can now be shown with normal tweets.
How Do I Install It?
You can download it from the WordPress repository here, and then install it as you would any old style WordPress plugin, which is as follows:
- Download the zip file and unzip it to somewhere, say your desktop.
- With any good SFTP client upload the extracted folder to your
wp-content/plugins/
folder. - Enable the plugin in the WordPress plugin page.
Of course you can also install it by using the WordPress auto installer.
How Do I Use It?
Due to Twitter not having a solution for open source applications using oAuth yet, you must follow some slightly more complicated instructions to sign in via oAuth. Comprehensive instructions are provided in the plugin but here is a rough overview.
First you need to register a Twitter App, save the consumer keys you are provided with, then sign in with Twitter. As I said more detailed instructions are provided as you set up the plugin, including tips for what to enter when registering you app.
Finally you can show your tweets using a widget. The widget is a WP 2.8 & up compatible widget. If you are using a WP version lower than 2.8 you should really upgrade for security reasons if nothing else.
If you are a good ‘ol fashioned function user then you can call Twitter stream using:
1 |
twitter_stream($arg); |
Providing either a keyed array or an argument list. All the parameters available are listed here.
How Do You Get Round The API Limit?
Now that oAuth has been implemented API requests will be counted against your personal account rather than your servers IP address meaning that shared servers should no longer cause a problem. However to reduce the possibility of overusing the API even further caching is still in use.
Sometimes I Get An Error Message!
There is a built in error message that is shown if Twitter fails to provide a vaild XML file. Reasons for this could be that the Twitter API is down (which Twitter claim is highly unlikely), or the plugin failed to read the cache file. If this happens, and you know Twitter is available, try deleting the cache file which is named username.cache
. You can do that using the brand new ‘delete cache’ button which is shown on the bottom of the authorization page. Just click ‘Twitter Stream’ under the settings menu to find it.
Sometimes The Date Is -xx Seconds Ago?
This is sometimes difficult to get your head around. Simply put it is caused by your servers clock being faster or slower than Twitters clock. To work out the time ago it takes the timestamp (number of seconds since Unix Epoc) and takes it away from the timestamp at which the tweet was posted. If your servers clock is slower than Twitters, for the first few seconds it ends up giving a negative value therfore seeming as if it was posted in the future. It could be something completely different involving Aliens, badgers and evil pidgeons, but that is the most sensible thing I’ve been able to come up with. If you have a better idea what it is let me know.
Sometimes oAuth Misses The Deny/Accept Page When I Press ‘Sign in with Twitter’?
This happens if you have already authorized Twitter Stream to be used with your Twitter account. Until you press the sign in button the plugin can’t tell if you have already given authorization or not. This generally happens if you have more than one blog using Twitter Stream with the same Twitter account. It’s perfectly normal though.
Can I Style It?
You can. I haven’t added any styles so I could keep the plugin on one file & keep it free of clutter. The available CSS classes are:
.at-reply
for @replys..hash-tag
for #tags.a.twitter-link
for autolinked URL’s within the timeline.a:hover.twitter-link
for autolinked URL’s within the timeline when they are hovered over.a.twitter-date
for the date permalink.a:hover.twitter-date
for the date permalink when it’s hovered over..profile-link
for the newly added link to user profile..follower-count
for the newly added follower count.
Can I Have A Options List?
Sure. The basic usage for in the template is this.
1 |
twitter_stream( [query-string/array] $args); |
Here is the info for each parameter.
username
should be a string and is the username of the Twitter timeline you want to return. No longer required. If omitted will show the user who authorized Twitter Stream’s timeline.count
should be a string and is how many tweets to return. Default ’10’.date
bool or string. If set to TRUE it will show the time ago with a hyphen as a default separator. If it is a string of anything other than ‘TRUE’, ‘true’ or ‘1’ it will use that as a separator.profile_link
a string. Allows you to customize what the link to your Twitter profile (shown at the bottom of the tweets) says. ‘Visit My Profile’ by default. Use a space, like this ‘ ‘, to show nothing.retweets
bool, true or false. Shows retweets with normal tweets.show_followers
bool, true or false. Shows the number of followers.cache_time
Set the length of time tweets are cached for.echo
Controls if the tweets should be echoed out to the page or returned as a SimpleXMLObject for manipulation via PHP. Defaults to TRUE, meaning echo tweets to page.
Here is an example using all parameters.
1 2 3 4 5 6 7 8 9 |
twitter_stream(array( 'username' => 'twitteruser', 'count' => '10', 'date' => FALSE, 'profile_link' => 'Visit My Profile', 'retweets' => FALSE, 'show_followers' => FALSE, 'cache_time' => 30, 'echo' => TRUE )); |
I Need A Translation!
You can download translations files for the plugin here. These are .po & .mo files in a zip for the languages available. For the translation to work you only need the .mo file placed in the same folder as the plugin.
- Swedish Translation – Thanks to Albert Johansson
- Belarusian Translation – Thanks to FatCow
- French Translation – Thanks to Tolingo.com
- Dutch Translation – Thanks to Rene
- Alternative Dutch Translation – Thanks to Sander Van Vliet
- Spanish Translation – Thanks to inMotion Hosting
- Serbo-Croatian Translation – Thanks to Borisa Djuraskovic (WebHostingHub)
- German Translation – Thanks to Stefan Moeller
I have provided the .po file for those who would like to amend or alter anything. Should you do that please send me a copy of the amended .po file so I can update the files here. If you would like to translate Twitter Stream into a language not available here you can download a blank .po file here. Once you’ve done the translation send it to me at admin [at] return-true [dot] com.
A huge thank you to those who have translated so far & a big thank you to anyone who may help in the future.
I Have A Feature Request! / I’ve Found A Bug!
You can report all bugs via the comments which I read as soon as I can, or you can send me an email via the contact page. Either way I promise to try and get back to you as soon as possible.
I Want To See A Working Demo?
Okay. Well the Twitter timeline here on Return True (on the right) is created using Twitter Stream. You can also see it on Medibolism & on Lisa Marie Art’s website.
Where Do I Get It Again?
Once again you can download it from the WordPress plugin repository here, or you can install it via the WordPress auto installer in your blog admin.
I Love It, Can I Give You Some Love?
Wait… What?!! Oh you mean that sort of love. Sure. 😛 You can help out in one of three ways. You can donate to help cover server costs & the cost of the coffee that keeps me coding. You can do that by clicking the button below.
You can buy me a present from my Amazon Wish List which would be very much appreated, or you can simply spread the word about Twitter Stream & The Attached Image.
Well that’s about it if you find any bugs or have any requests let me know.
Note: Twitter bird artwork in header image created by lisa-marieart.com. Used with permission.
445 Comments
Michael Mason
Thanks. I will!
Have a good evening. 🙂
Lucas Mattos
Hey, ty for the cool plugin, but i followed the installation instructions by letter, everything seems right, no error messages in any part of the installation, but i keep getting this on the front-end page:
Warning: chmod() [function.chmod]: Operation not permitted in /home/lucasmattos/www/blog/wp-content/plugins/twitter-stream/twitter-stream.php on line 270
Warning: fopen(/home/lucasmattos/www/blog/wp-content/plugins/twitter-stream/authuser.cache) [function.fopen]: failed to open stream: Permission denied in /home/lucasmattos/www/blog/wp-content/plugins/twitter-stream/twitter-stream.php on line 271
Warning: flock() expects parameter 1 to be resource, boolean given in /home/lucasmattos/www/blog/wp-content/plugins/twitter-stream/twitter-stream.php on line 272
Warning: fclose(): supplied argument is not a valid stream resource in /home/lucasmattos/www/blog/wp-content/plugins/twitter-stream/twitter-stream.php on line 276
Warning: chmod() [function.chmod]: Operation not permitted in /home/lucasmattos/www/blog/wp-content/plugins/twitter-stream/twitter-stream.php on line 277
********************
Well, i guess its something with the twitter oAuth or some folder permission, can u help me?
Lucas Mattos Part2
Hey, sry, i forgot to mension that my tweets appear after those error messages and i already clear my cache. Thank You again.
Paul Robinson
Hi Lucas,
Sorry for the problems. I’ve been emailing back & forth with someone else who has exactly the same problem.
It’s something to do with file permissions & the fact that PHP (on your server) doesn’t have permission to change the permissions of the cache file so it can read & write to it. Your best bet for the moment, while I try to figure out how to fix it, is to set your PHP error reporting to off.
The errors will not cause anything bad to happen they are just occurring because of said permissions problem.
Also if you could tell me the name of your host it might be helpful in figuring out how they have PHP setup on the server.
icute
Hi there,
Just tonight i upgrade ya plugin and at first it works like charm, then while working on my page i notice the plugin is not working, i got this notification:
” The plugin twitter-stream/twitter-stream.php has been deactivated due to an error: Plugin file does not exist”
is this error occur because im suing auto update?Kindly advise me what to do or should i reinstall it again?
Paul Robinson
Hmmm. I think I might know what the problem is. I’d hold off upgrading until I release a small update. I’ve been trying to fix the file permissions problem mentioned by Lucas & another user & it seems to have had an odd side effect for some users.
Try deleting the plugin & then try reinstalling in about 20-30 minutes just to give the WP server time to update.
icute
To delete the plugin i notice the plugin was not shown in the wp admin panel of plugin but i check at my cpanel the folder is there so i try to delete it manually.
Ironically, the file of twitter-stream magically reappears. Even if I overwrite a file the original reappears. I cannot reinstall the plugin as it detects the old file.
I have try reinstall both ways in wordpress and via cpanel(manually) also but no luck.Is it something do with the permission or my host?
Paul Robinson
Defo a permission problem. I’m not sure how much you know about file permissions but basically while trying to fix a problem someone else was having (turned out to be their host) I told the plugin to set the cache file it writes too to 0644 sometimes this can make strange things happen. I’ve set it to 755 now which should fix the problem but you need to try to delete the old Twitter Stream folder.
Can you log into FTP or preferably SFTP with something like Filezilla & change the Twitter Stream’s folder permissions (chmod) to 755. You should be able to delete it then. If you can do that with cpanel (I haven’t used it before) then feel free to do it that way.
Let me know how it goes & I apologise for the problems. If you still have problems even with the new version let me know & I’ll remove the chmod from the plugin completely as it’s just there as a failsafe for certain servers.
icute
To make sure the old file deleted and not appearing again,i change the perm to 0755 and i did manage to reinstall the twitter stream once again.It works but not for long, i notice then its gone again after i refresh my page. I keep changing the perm back and forth to see the stream, it seems wont sit still there everytime i refresh my page.. huhu what should i do now?
Paul Robinson
I’m going to remove the chmod from the plugin. It’s clearly causing to much trouble with users, like you, who wouldn’t normally have any problems.
I’d rather keep the users who are currently using Twitter Stream, like you, happy than have to try to fix problems caused by web hosts not setting up their servers correctly.
If you can wait about 15-30 minutes again to give the WP SVN server time to catch up then try reinstalling again hopefully it will work properly.
icute
ok paul, i can wait 🙂 thanks so much, hoping it will be back as usual 🙂 i will let u know the result after done reinstalling again.
tqvm
Paul Robinson
No problem. I’m just sorry that trying to fix someone else’s problem has caused problems for you.
Hopefully this update will fix everything. The version you are looking for is 2.2.3 so if the WP plugins page says that you can reinstall & it should fix your problems.
icute
Hi Paul,
ive reinstalling it and its working like normal now.
Thanks for the help.Im sure will promote your plugin to my friends 😉
Paul Robinson
No problem.
Thank you, and sorry for all the problems in the first place.
Jonny Vaughan
Hi Paul,
The regular expression you use to match URLs in tweets needs a bit of adjusting I think. It doesn’t match http://t.co/ shortened links.
My regex skills aren’t up to much otherwise I’d offer a solution.
Thanks
Jonny
Paul Robinson
Hi Jonny,
Thanks for letting me know. I realized a day or so ago, but I’ve been unable to come up with a solution myself.
My regex skills aren’t amazing either unfortunately. I think it’ll be a little bit of trial an error to get it working. I’ll see if I can get it sorted in the next few days.
Thanks again for telling me. 🙂
Jonny Vaughan
Hi Paul,
No problem – I’ll have a play around with the regex myself and see if I can get anywhere with it. If so, I’ll post back my solution.
Thanks for the quick follow up 🙂
Jonny
Paul Robinson
Thanks,
Any help you can give would be much appreciated.
Jonny Vaughan
I reckon this will do the job. It removes the requirement to have two letters in one or more of the first parts of the domain.
I’ve tested using one of my client’s development websites here: http://makespurple.10degrees.co.uk/ – cleared the tweet cache & refreshed the stream and t.co URLs now link correctly.
Hope this helps!
Jonny
Paul Robinson
So that is what the problem was. I was just going to look but I’ve been away from my computer.
That looks perfect thanks for your help. I’ll replace the old regex when I get back to my computer. 🙂
Paul Robinson
Just to let you know I’ve updated the plugin. Thanks once more for your help. 🙂
Lord Kamina
Hey, I haven’t tried your plug-in yet (I did install it, and am messing around with the styling, etc)
What I need to know is it supports more than one twitter account? I want to have feeds for two different accounts on different pages (not mesh them up together), can your plug-in do this?
Thanks in advance!
Paul Robinson
Hi,
I’m actually not sure. You wouldn’t be able to via the widget, but you might be able to using the PHP function on two different pages.
I’m going to be out most of today or I’d try it out for you. If you do give it a go I’d love to here if it works. 😉
Lord Kamina
Well, actually… I just tried adding the widget twice to the side bar and I could configure each instance of it separately, so I didn’t have any trouble at all adding two different streams.
Still, I’m probably gonna end up using the function in the end, since I don’t want the streams to appear on every single page.
Paul Robinson
The function should work okay. I’m nicely surprised that two widgets work though. I had a feeling they wouldn’t. Glad I was wrong.
Just remember you’ll only be able to pull public Twitter accounts back unless touch are authorized as the user with the protected account. Other than that though you shouldn’t have a problem.
Lord Kamina
Yeah, the accounts aren’t protected; I wonder, though, if I gave TwitterStream access to two different accounts, maybe I could pull them even if protected?
Paul Robinson
I’m not sure. Normally you can only get access to the authorized account. However if you can manually add the app to the twitter account on Twitter’s site it may work.
joe
Hello,
your Plug in seems to be one of the best plug ins for twitter I could find till now. If styled nicely it’s better readable than most other twitter plug ins I’ve tested. However, I have a small problem here.
The plugin shows my tweets the way it should, but on top of them it shows the following error messages:
Warning: fopen(/www/htdocs/serveruser/wordpress/wp-content/plugins/twitter-stream/authuser.cache) [function.fopen]: failed to open stream: Permission denied in /www/htdocs/serveruser/wordpress/wp-content/plugins/twitter-stream/twitter-stream.php on line 269
Warning: flock() expects parameter 1 to be resource, boolean given in /www/htdocs/serveruser/wordpress/wp-content/plugins/twitter-stream/twitter-stream.php on line 270
Warning: fclose(): supplied argument is not a valid stream resource in /www/htdocs/serveruser/wordpress/wp-content/plugins/twitter-stream/twitter-stream.php on line 274
Do you know how I can fix this?
Paul Robinson
Hi Joe.
Thanks for the kind words. Unfortunately I’ve encountered this problem before but I’ve never found a fix for it.
The nearest I could come to finding out what was going on was something to do with file permissions.
I’ll certainly look into it if you are willing to work with me to help fix the problem. Since I can’t reproduce the error I’d need your help to see if the problem is fixed.
If you could ask your host if PHP scripts have write permissions when using fopen it would be extremely helpful.
Staff
Hi there,
I can tell you exactly what the problem is.
When you do the installation the cache file is not created automatically on some hosts (this includes mine)
The error is caused by the plugin is trying to open a file called .cache in the wp-content/plugins/twitter-stream folder.
So if your twitter username was brian1986, the file brian1986.cache is not created on install.
To fix this problem just create a text file on your desktop, rename is to your .cache. upload it to the twitter-stream folder (IE the root folder of the Twitter plugin) then set the permissions on it to 666 via CHMOD.
You should find this take away your headache.
🙂
And thanks for this plug, it’s really very good indeed.
Barry Deck
Hi Joe.
I’m not sure why I can’t get it to work. I went through the auth process and it said congrats, it was authorized, but i continue to get an error message where my feed should appear. when i press delete cache, it says “Cache Deletion Failed!” I looked for the cache manually and it seems to be absent or invisible.
Any suggestions?
Barry
Paul Robinson
Hi Barry,
Have you tried the fix mentioned above your comment? It is the only way I know of to fix this problem as it is caused by your host using extremely restrictive
fopen
settings.I could remove the caching system & it would fix the problems, but that would mean that everytime someone visited your page they would use 1 of your Twitter API requests and you only get 120/150 per hour.
I am however working on other solutions, but they are a little way out yet.
Barry Deck
Hi Paul.
Yes, I have tried it and it seems not to make any difference. If I delete the cache as the documentation suggests, it does not replace it. Will look into whether I have control over fopen settings on my hosting account, otherwise not sure what to do. Would love to have a twitter feed on my site.
: /
Paul Robinson
If you have tried creating the file yourself & chmoding it to 666 as Joe suggested then I’m afraid I don’t know of any way to help.
If you get any joy with your host & fopen please let me know. In fact if you can ask them what method they recommend to use to create & write to files using PHP it would be very helpful. If you do ask them please send the info to admin [at] return-true [dot] com & it will be an amazing help in trying to fix this problem.
@LoriOnline
My link to profile link is not linking to my profile. Where can I change this so it works correctly?
Paul Robinson
Hi Lori,
You can’t unfortunately (not without editing the file directly). You have however found a bug I missed, so thank you for finding it.
I’ve just fixed it & I’m uploading the fixed version to the WP plugin repository now so it should be available via the update soon.
@LoriOnline
I re-installed but now when I hit “sign in with Twitter” in WP it tries to open my blog and I get the white page. Can you help?
Paul Robinson
I’m not sure what you mean. Once you’ve authorized Twitter Stream once you don’t need to do it again after an upgrade. It should just work like before.
All that was changed was a small spelling mistake in the code. I’ve given everything a test though, just in case, but everything seems to be working okay here and on a couple of other sites that use the plugin.
Can you give any more details that might help me diagnose the problem?
Icute
awesome updates Paul! actually i have notice it long before but i thought its just me, until LoriOnline mention it haha silly me, but again thanks for updating it paul. WPtwitter stream rox!
Paul Robinson
Thanks.
I’m just a little confused at the problem. Here is a picture of what I get straight after upgrading to the latest version of Twitter Stream. http://twitpic.com/4fnuye/full
As you can imagine, since I can’t replicate the error it’s extremely hard for me to figure out what is going wrong. 🙁
Icute
The one that im notice before is the linking to the twitter profile. Im not sure why LoriOnline get the white page. I’m so sorry paul i wish i could help ya on this but im not techy person.
My guessing its the cache problem, btw i will try to install it at my other blog and see how its going.
Paul Robinson
Ahh. I’m sorry I thought you meant the white page problem. The profile link should be fixed now since version 2.2.5. Is it still not working? It seems to be working now on my local install. The bug was just a small spelling mistake & should be working okay now.
Icute
Its working purrrrfectly paul! thanks
if you like i will try install the plugin at my other blog and see what LoriOnline meant. 🙂
Paul Robinson
If it’s not too much bother. I’ve just taken a look at Lori’s site and it seems to have deactivated itself, but I’m not sure how.
If you are reading this Lori, could you check in your authorized apps list on Twitter to see if your site is still listed as an authorized app. If you are using new twitter you log in to their website and press the drop down menu with your username on in the top right corner & pick settings. Then press the connections tab. You should be able to find the name you used when you first authorized Twitter Stream. If it’s there try revoking access and trying again from the admin page of Twitter Stream in WP’s back end.
I’m not sure why this is happening. I’ve never come across anyone with this problem before but I’ll try my best to help you out.
Icute
Ok paul i have tested it using my 2nd twitter account and 2nd blog. All works like a charm. No white page or anything.
Hoping it will gave ya some hints on what exactly happened to LoriOnline. I also visited Lori’s webpage and yeah it shows deactivated.
Paul Robinson
Thanks for checking. I’m not sure why that is happening to Lori. It sounds like Twitter has de-authorized the plugin for some reason. I have no control over any of the authorization steps as they are provided by Twitter’s oAuth system. All my code does is store some data so that it can identify itself when Twitter asks if it has been given authorization to access the Tweets.
It’s really strange. 🙁
@LoriOnline
So I totally started from scratch and got the stream working, back to the original issue of the link to twitter going to nowhere. Just try the link at the end of the stream and let me know if you get sent to my twitter. http://www.lorirobertsonlineblog.com. THANKS for helping though. At least I got it back to where I was yesterday. I am getting around the broken link by just pointing people to the tab “follow me”.
Paul Robinson
Well I can see what you mean, but if you take a look at the source code it really is pointing to http://twitter.com/lorionline, I can only think there is something else that is causing the problem. I’ve have checked as much as humanly possible & there is nothing I can think of that would cause that problem except for something interupting the browsers normal hyperlink processes.
I’ve just ran a quick test using the Net panel of Firebug and it seems that when you click the link it tries to go to Google Analytics site, but is quickly aborted (by the server). Then for some reason (which I’ve yet to figure out) it thinks it has successfully loaded Twitter… What is happening is anybody’s guess, but you could try deactivating Google Analytics temporarily to see if it fixes the problem.
The thing that I’m struggling to figure out is why only on that link, and why is it only occuring on your site as I’ve used Twitter Stream on other websites with Google Analytics active with no problems. 🙁
Icute
I have tried the link and it does not go anywhere, thats weird cuz mine works well.
Paul Robinson
I think Google Analytics is causing problems although I’m not sure why as it hasn’t in the past. 🙁
@LoriOnline
It is working perfectly now! Thanks for hanging in there with me. I don’t even use google analytics and I did have a plug in activated so I deactivated it and voila! Took a day to kick in but all is good.
Paul Robinson
Great to hear Lori. Not sure what caused it to take so long to start working, but I’m glad everything is up & working like it should be. 🙂
Oh, and don’t worry. I’m always happy to help. 😉
flo
hi there,
is it possible to show a whole timeline of the people i follow?
Paul Robinson
Hi Flo,
Unfortunately you can’t do that with Twitter Stream. It is only designed to pull back your own Tweets. Sorry.
Steve
When I go to connect after entering my keys (this url: .. wordpress/wp-admin/options-general.php?page=twitterstreamauth&wptwit-page=redirect) I get a blank page.
When I tested this in my local environment, it worked fine. Ideas?
Paul Robinson
Unfortunately I can’t think of anything that would cause that.
Without an error message its hard to tell. However that url suggests that the redirect isn’t working. That shouldn’t really prevent it from working though if that was the problem. If you click the Twitter stream link in the menu does it say its activated or take you back to the blank page?
Paul Robinson
Yes the variable is in seconds.
C
Nice stuff
Im looking fore something that can show the tweets from the ppl that I follow.
so…not my own tweets
is this possible?
Paul Robinson
Unfortunately Twitter Stream isn’t designed to do that. Sorry.
Danny
Thank you, Paul, for an excellent lightweight plugin. I had tried two others but the sheer weight of .js and calls to Twitter was impactimg site performance.
Plus, one of them resulted in 20+ 3rd party cookies from Twitter being downloaded to my site’s visitors.
The only issue I experienced with your plugin was exceeding 350 API calls in the first hour. Obviously the cache feature was not working. Reading Staf’s comment above of 18.03.2011 I guess the cache file was not created on my server.
I am getting around the problem temporarily with the help of WP Widget Cache.
What exactly is the cache file name supposed to be?
Is it:
mytwittername.cache ??
Best wishes,
Danny
Paul Robinson
Hi Danny,
No problem, I’m glad you like Twitter Stream.
I’m not sure why the cache file creation is such a huge problem on certain servers. I’m going to have to look into it further and see if I can find out what is causing all these problems.
Yes, the cache file should be one of the following. Either ‘authuser.cache’ if you authorized Twitter Stream but you chose not to enter a username in the widget/function options, or ‘twitterusername.cache’ if you chose to enter a username in the widget/function options. Obviously ‘twitterusername’ would be the Twitter username you entered, not your Twitter username.
Danny
She be blowing trumpets now, Paul !! Good man. Thank you.
I created both versions of the file naming convention just to be sure, but as you predicted, the authuser one is now being populated because I did not enter a user name on initialisation.
Really appreciate your rapid response on a bank holiday weekend Sunday evening. I would not worry about the install procedure not creating the cache file. Many plugins that require file creates do not achieve that on my VM. I think I may have buggered up the permissions structure somewhere along the way, not being a Linux admin.
But maybe do stress that in your install notes – like get the user to check that the file exists and, if not, tell them to create it as Staff and you described here. Especially CHMOD 666.
Hopefully you will eventually get to the bottom of the error condition “Your Twitter stream could not be collected. Normally this is caused by no XML feed being returned. Why this happens is still unclear.”
Or revert to the cached data if that happens.
(Maybe you already do – I removed the WP Widget Cache “protection” from Twitter Stream after creating the cache files. That error message then displayed for maybe 15 minutes – possibly a coincidence. Then it all clicked in and is running fine. As is the profile link that did not work earlier.)
Cheers,
Danny
Paul Robinson
No worries Danny.
The error message is due to the cache file not being created and would have not been corrected for 15 minutes as that is how long the cache takes to refresh. You can turn the cache timing down as low as 30 seconds if you want & you should still not run out of API requests.
I’m thinking of changing to a file caching system that checks for write privledges & then moves to using the WP database if it cannot create the file. That would solve the whole file permission problems. That’ll be for later though. 😉
I’ll add into the post tomorrow about the caching problems. It should have been done a while ago but never managed to get round to it with the crazy holidays (Royal Wedding etc) and a sudden barrage of work popping up. 😆
Anyway. Glad everything is now up and running. Enjoy the rest of your long weekend. 🙂
Dan
Hey Paul,
Great plugin! I’ve chopped and changed through about five different Twitter widgets and yours looks like the most promising so far.
The only thing I’d like to know is if it’s possible to remove my @replies from the feed, and instead only show my tweets that are written for all to see?
Your help would be greatly appreciated.
Thanks,
Dan
Paul Robinson
Hi Dan,
Sadly I don’t think it’s possible to remove @replies from the feed. You can remove retweets, but not @replies.
CB
I’m using custom fields in WordPress and was wondering how I could use a custom field to dynamically populate the username field in the array within the template. Right now, I have code like this, but its not working. I’d like to use a custom field to input the username per post. My custom field label is “twitter” for each post.
Twitter Feed ”,
‘count’ => ‘6’,
‘date’ => TRUE,
‘profile_link’ => ‘Go to Twitter »’,
‘retweets’ => FALSE,
‘show_followers’ => FALSE,
‘cache_time’ => 30
)); ?>
Thanks for any insights, great plugin!
CB
Ok, so that didn’t post correctly. 🙂 Here is the critical portion of what I was intending to copy/paste.
[code]
twitter_stream(array( ‘username’ => ‘<?php echo get_field("twitter"); ?>’,
[/code]
CB
[code]
<?php if(get_field(‘twitter’) != ""): ?>
<div class="twitter"><h4><?php the_title(); ?> Twitter Feed</h4><?php twitter_stream(array( ‘username’ => ‘<?php echo get_field("twitter"); ?>’,
‘count’ => ‘6’,
‘date’ => TRUE,
‘profile_link’ => ‘Go to Twitter »’,
‘retweets’ => FALSE,
‘show_followers’ => FALSE,
‘cache_time’ => 30
)); ?></div>
<?php endif; ?>
[/code]
Paul Robinson
Hi CB,
It should be possible although I must admit it’s something I haven’t thought about.
Normally to get the value from a custom field you use the function
get_post_meta($post->ID, 'twitter', TRUE);
.Give that a try and let me know how it goes. If it doesn’t work I’ll see what else I can come up with for you. 😉
CB
Thanks, Paul. It seems like the single quotes are throwing things off, as I just get a blank white page when I include that. As you can tell, I’m a bit of a hack when it comes to PHP, so I’m not sure how to write that correctly. Here’s what I have. This is working in other areas of my site, so I’m confident that the syntax is correct, but feel like maybe the single quotes I’m not writing properly within that array. Any thoughts? I’ve tried double quotes around “twitter”, but then it just says nothing found.
[code]
<?php twitter_stream(array( ‘username’ => ‘<?php the_field(‘twitter’); ?>’,
‘count’ => ‘6’,
‘date’ => TRUE,
‘profile_link’ => ‘Go to Twitter »’,
‘retweets’ => FALSE,
‘show_followers’ => FALSE,
‘cache_time’ => 30
)); ?>
[/code]
Paul Robinson
As far as I’m aware it should just be:
CB
Ah, thanks! Removing the unnecessary ?php stuff got it all running for me. Thank you!
Paul Robinson
No worries. Glad to help.
Paul Robinson
No worries. Glad to help. 🙂
Kari
Hello, thank you for writing this plug-in and sharing it with all of us. I’m wanting to embed my twitter stream into a post, so that it doesn’t appear on every page. More specifically I want to put it into the slide of a SlideDeck. Posts don’t accept php hard coding, is there by any chance a short code I can use to embed it in my post/page?
Paul Robinson
Hi Kari,
Sorry unfortunately there isn’t a shortcode available. However you could try the following.
Open up your theme’s functions.php file, if you don’t have one create it. Then add in the following code to the bottom:
I’ve tested it a little & it seems to work okay.
You should be able to use it by adding a shortcode in your post, something like:
Basically all the parameters listed in the post above will become parameters for your shortcode.
Again I’ve only quickly tested this, but hopefully it will work. The benefit with this is that you won’t lose your shortcode if you update Twitter Stream. I haven’t added it into the plugin as of yet, but I plan to soon.
Glad you like the plugin & you’ve made me want to go watch an episode of Mythbusters, thanks. 😉
Florin
Heya! Great plugin! Can it show avatars of tweeter users?
Thanks!
Paul Robinson
Hi Florin,
Thanks. Unfortunately no it can’t. I may see if I can add that feature in the near future though.
Eddy Bauer
realy great plugin Paul!!! 🙂
I look forward to the avatar-feature…
Paul Robinson
Hi Eddy,
Thank you. I plan to add it into the plugin very soon, I’m having some major website stability problems as the moment so I need to get them sorted. Plus I’m way behind on implementing the new design for the site. Hopefully once all that is done I’ll be able to get the avatar feature added in.
Please feel free to nudge me if I haven’t added it in the next few weeks, I have a terrible memory sometimes. 😉