Twitter Commenters is a plugin for Movable Type that enables commenters to sign-in and comment on your blog using their Twitter account. Versions 2 includes support for Twitter's OAuth authorization system and enables commenters to automatically share their comments to their Twitter stream.
Basic Auth (default):

OAuth:


Twitter comment authentication works like other auth methods in MT -- once you have installed the plugin you can enable Twitter as one of the auth options, as shown in the image above.
How It Works - Basic Auth
When the user enters their Twitter username and password in the form (shown above), the plugin submits those to the Twitter API to verfiy the credentials. If verified, the user can then post comments using their Twitter account. Their Twitter 'display name' will be shown beside their comments, and their Twitter avatar (profile photo) will be imported and shown beside their comments (if userpics are enabled in your templates).
Note that users' Twitter passwords are not stored in the MT database. An upcoming version of this plugin will enable Twitter's new OAuth support, in which case passwords would never be sent to MT at all. That version will like have an option for commenters to cc. their comments to their Twitter account. Stay tuned.
How It Works - OAuth
New in Version 2.0, you can optionally enable Twitter's new OAuth authorization system. With OAuth, user never have to submit their password info to your server. Instead, they click a "sign in with Twitter" button and they are taken to a page on Twitter.com asking them to authorize the application (see image above). One they click "Allow" they are returned to your site and they then post comments using their Twitter account. As with basic auth, their Twitter 'display name ' will be used as well as their Twitter avatar (profile photo).
Share Comments on Twitter
A new feature in version 2.0, only supported via OAuth, enables commenters to optionally share their comment to their Twitter stream. All they have to do is click a checkbox, no need to re-authorize or enter Twitter account info.
Try it Now
MT Hacks has the new OAuth method enabled. Try it now:
Click here to login with your Twitter account. After logging in, you will be returned to this entry, and you can leave a comment below.
Requirements
- Net::Twitter 2.07 perl module (included with plugin) (note: do not upgrade to version 2.9+ of this module)
- Net::Twitter::OAuth perl module (included with plugin)
- Net::OAuth perl module (included with plugin)
- Net::OAuth::Simple perl module (included with plugin)
- JSON::Any perl (included with plugin)
Note: Net::Twitter requires newer versions of the libwww-perl collection of Perl modules. I am not sure what the minimum version required is, but on my server, I had to upgrade in order to get Net::Twitter to work. So if you get strange errors, try installing the latest version in your 'extlib' directory of your MT. Update: A common error message is: "Can't locate object method "default_header" via package "LWP::UserAgent" -- if you see this error, this the problem.
Download Twitter Commenters
Installation
- Upload the contents of the 'plugins' folder to the 'plugins' directory for your MT install.
- Upload the contents of the 'mt-static' folder to your 'mt-static' directory.
- For each blog you want to enable, go to Preferences > Registration and check the box for 'Twitter'.
Enabling Twitter OAuth
Unfortunately, this is not as easy as it could be, maybe Twitter will make it easier in future. To set this up you need to create an Application on Twitter:
- While logged in to your Twitter account, go to http://twitter.com/oauth_clients/new.
- Fill out the form on that page:
- Give it a unique name and description.
- For 'Application Website', enter http://mt-hacks.com/twittercommenters.html. For 'Organization', enter MT Hacks.
- For 'Website' enter http://mt-hacks.com.
- For 'Application Type' choose 'Browser'.
- For 'Callback URL' enter the full URL to your comments script followed by '?__mode=login_external&key=Twitter'. Example: http://www.domain.com/cgi-bin/mt/mt-comments.cgi?__mode=login_external&key=Twitter
- For 'Default Access type' choose 'Read & Write'.
- Check the box for 'Yes, use Twitter for login'
- Hit the 'Save' button.
- After saving the application, you should now see a screen with a 'Consumer key' and 'Consumer secret'. Copy those to the system plugin Settings (System Overview > Plugins > Twitter Commenters > Settings). and save the plugin settings.
- To enable the share comment on Twitter option, add the <mt:TwitterShareCommentOption> tag below the comment text part of your comment form. This will display a checkbox option to people logged in via Twitter OAuth.
- Rebuild your entry pages and test it out
As always, feedback is appreciated.
Follow @mthacks on Twitter for updates and other MT and Twitter hacks.


Comments (39)
Just an example of a blog comment shared on Twitter via Oauth
Update: Here is the tweet.
Posted by Mark Carey
|
June 1, 2009 9:57 AM
Posted on June 1, 2009 09:57
Mark
I'm getting the following error:
" Can't locate object method "default_header" via package "LWP::UserAgent" "
Any ideas?
Michele
Posted by Michele | June 1, 2009 10:16 AM
Posted on June 1, 2009 10:16
I'm getting the same error as Michele.
Posted by quack | June 1, 2009 11:31 AM
Posted on June 1, 2009 11:31
Weird, it posted that twice... and NOW I see you've actually mentioned this error. I skipped that part apparently.
Posted by quack | June 1, 2009 11:42 AM
Posted on June 1, 2009 11:42
@mneylon: that exact error is mentioned in the the post (with solution) ;)
Posted by Mark Carey
|
June 1, 2009 12:18 PM
Posted on June 1, 2009 12:18
Upgraded the perl modules server-wide.Still getting the error :(
Posted by Anonymous | June 1, 2009 12:26 PM
Posted on June 1, 2009 12:26
LWP::UserAgent v 2.032 (Jun 2004) is required for Net::Twitter. I've made the appropriate change to Makefile.PL. A Net::Twitter maintenance release will be uploaded to CPAN soon.
Posted by semifor | June 1, 2009 12:29 PM
Posted on June 1, 2009 12:29
Mark will this or could this (eventuall) work for user entries? For example if you are running the Community Solution and let users post new entries - could those new entries also be sent to the user's Twitter account and/or could they log into MT with the Twitter info?
Posted by Anthony | June 2, 2009 6:47 PM
Posted on June 2, 2009 18:47
My LWP::UserAgent on the shared server I'm using is out of date. I've used CPanel to invoke CPAN to update LWP::UserAgent to the latest version, which it's done successfully, and installed the modules in /home/myusername/perl. However, I don't have read access to this directory, only write and execute access, so I can't copy the files to the extlib directory.
I've tried adding the the module location to mt.cgi, mt-cp.cgi and twitter.pm using 'use lib /home/myusername/perl'. However, I still get the standard 'can't locate object method' error. Is there a way to get the plug-in to look in the right-place for the correct version of LWP::UserAgent? Would a symbolic link somewhere work (created by a one-off cron job since I don't have command line access on the server)?
Posted by Anonymous | June 13, 2009 7:35 PM
Posted on June 13, 2009 19:35
Hi Marc,
the cronjob, polling my Action Streams, is throwing errors since I installed your plugin:
"my" variable $key masks earlier declaration in same scope at [yadda-yadda]/cgi-bin/mt/plugins/TwitterCommenters/TwitterCommenters.pl line 124.
Do I have to take this serious?
Posted by Yves
|
June 15, 2009 11:59 AM
Posted on June 15, 2009 11:59
I've managed to upgrade LWP::UserAgent and install it in extlib now. However, what I get when I try to sign in with Twitter is "Can't call method "permalink" on an undefined value". Any ideas?
Looking forward to getting this work, because it promises so much!
Posted by Anonymous | June 17, 2009 6:57 AM
Posted on June 17, 2009 06:57
Hey I'm Jamie M. Slaton resident of South Carolina and my interests are fashion and law educations. I'm taking part in a fight against crime. There are many crimes that are happening nowadays and I think it's better to make a movement out of this. We need to start a rundown of what's going on in our country. For instance, there are corrupt government officials that are letting criminals out of bars. It should stop and most probably end these wrong deeds. Even though these culprits escaped, can easily find out what and where they can be found. We just need to search for criminal records of these escaped convicts. So if anyone interested to fight these things, we should start now.
Posted by Jamie M. Slaton | June 17, 2009 3:29 PM
Posted on June 17, 2009 15:29
twitter is a good appplication i used it and found good to reach owner
Posted by Neetu Sharma | June 18, 2009 8:35 AM
Posted on June 18, 2009 08:35
I've got a bit further now. The 'permalink' error stems from the fact I'm using MT Pro. The Twitter.pm library seems to want a CGI parameter that doesn't exist with the mt-cp.cgi script - 'return-to' - when it really wants 'static'. I edited Twitter.pm to use that instead.
All works fine after that as far as I can see with regards to authentication at Twitter. However, the value of 'static' is URL encoded so won't return the user to the right location. However, by invoking url_decode() (and 'using' the appropriate library at the beginning of Twitter.pm) before submitting it to the return_to cookie, you can get that bit to work fine.
The final problem is trickier - for some reason, no user ends up being created in the user database, even though the plug-in correctly grabs the Twitter pic, etc. Equally, the wrong cookies appear to be used - the old style, non-community cookies for name, etc, rather than the single 'mt_blog_1' cookie. That means the 'authentication_type' cookie also doesn't get wiped on logout, meaning that if you log in with Twitter, you don't get signed in and you always get the 'Share this comment on Twitter' option, even if you sign out and sign in with a different authentication method.
No idea how to fix it and I've been experimenting a lot!
Posted by Rob | June 22, 2009 4:46 AM
Posted on June 22, 2009 04:46
I have the same problem as Rob above - getting an error about not being able to call the permalink method.
I looked at the code and found the follow lines:
if (!$return_to) {
my $entry = MT->model('entry')->load($entry_id) if $entry_id;
$return_to = $entry->permalink . '#_login';
}
The problem here is that if #entry_id does not exist, $entry does not exist on the following line.
I changed it to: if ( !$return_to && $entry_id ) and it logged me in, but put me in the wrong place.
I also noticed that it does not add me to the database, but I find that this is true for other login methods too.
thanks
Andrew
Posted by Anonymous | June 22, 2009 11:39 PM
Posted on June 22, 2009 23:39
Having the same problem as the other fellows, apparently -- Twitter comments don't appear to work on an MT Pro install. Any idea if this is something you can fix? (Or be bribed to fix? :))
Posted by Anonymous | July 6, 2009 10:45 PM
Posted on July 6, 2009 22:45
Thanks Anil, and thank you Rob all the detailed info -- very helpful stuff.
It seems I need to test the plugin against MT Pro and make some tweaks to accommodate some the peculiarities of the mt-cp script. Stay tuned for an update.
Posted by Mark
|
July 7, 2009 8:09 AM
Posted on July 7, 2009 08:09
Thanks for the new release - hopefully it will work on my install now :)
Posted by Michele Neylon
|
July 13, 2009 8:42 PM
Posted on July 13, 2009 20:42
if you get a "JSON::Any version 1.19 required--this is only version 1.18" error, here is the likely fix:
This is probably happening because you have the Facebooker Commenters plugin installed, which includes JSON::Any 1.18 in its /extlib/ and this is conflicting with v1.19 that is included with Twitter Commenters.
To fix, go to:
/path/to/mt/plugins/FacebookCommenters/extlib/JSON/
and delete Any.pm
This won't break anything, as
Posted by Mark Carey
|
July 14, 2009 10:38 AM
Posted on July 14, 2009 10:38
Three installs, three lots of:
Can't locate object method "default_header" via package "LWP::UserAgent"
I've been trying to figure out how to install the missing Perl modules to extlib, but haven't been able to do so. Could you (or anyone?) perhaps give more detailed instructions, or provide the relevant files?
Posted by Adam Tinworth | July 15, 2009 5:54 PM
Posted on July 15, 2009 17:54
Sure, Adam. Its quite easy.
Posted by Mark Carey
|
July 19, 2009 8:48 PM
Posted on July 19, 2009 20:48
Thanks for the new release - hopefully it will work on my install now
Posted by دردشه | July 22, 2009 10:40 AM
Posted on July 22, 2009 10:40
Testing commenting on blog of MT-HAcks and Twitter
Posted by Hans Mestrum
|
July 25, 2009 4:07 AM
Posted on July 25, 2009 04:07
When will it be the otherway round, so people commenting on Twitter posted as blogcomment on the blog?
Great to see this working.
Posted by Hans Mestrum
|
July 25, 2009 4:10 AM
Posted on July 25, 2009 04:10
He can't see a logout button.....
Posted by Hans Mestrum
|
July 25, 2009 4:12 AM
Posted on July 25, 2009 04:12
"Share Blog Comments on Twitter (plus OAuth Support)" is an excellent post. It is very informative. Thank you so much.
Posted by Essay Writing | September 15, 2009 12:25 AM
Posted on September 15, 2009 00:25
This is a great plugin. I love it
Posted by Alireza Malekiha
|
October 23, 2009 9:36 AM
Posted on October 23, 2009 09:36
Interesting option to preview comments Twitter. I like very much. Also following the Google Wave embed discussion. Keep up the good work.
Posted by Jason Bunston
|
October 28, 2009 11:19 AM
Posted on October 28, 2009 11:19
site..= http://ezlaptop.com/?r=341553) visit this site and win a laptop today but type
the whole site address..type
including d num
Posted by sushi | November 28, 2009 7:36 AM
Posted on November 28, 2009 07:36
I’ve been wanting to spend more time on twitter to engage with my peers and individuals I want to learn from. This is exciting news!
Posted by Google Wave Forum | November 30, 2009 3:10 PM
Posted on November 30, 2009 15:10
That is very good news for all bloggers round the world
Posted by BPO and Web Development | November 30, 2009 3:14 PM
Posted on November 30, 2009 15:14
That is very good news for all bloggers round the world
Posted by BPO and Web Development | November 30, 2009 3:16 PM
Posted on November 30, 2009 15:16
Test
Posted by Christoph
|
December 1, 2009 8:16 AM
Posted on December 1, 2009 08:16
tt4t4t4
Posted by Christoph
|
December 1, 2009 8:17 AM
Posted on December 1, 2009 08:17
This is a test using Twitter Connect.
Thanks a lot.
Posted by Christoph
|
December 1, 2009 8:18 AM
Posted on December 1, 2009 08:18
That is very good news
Posted by دردشه صوتيه | December 12, 2009 8:11 AM
Posted on December 12, 2009 08:11
thanks i have been searching on this article about twitter
Posted by rental mobil | January 16, 2010 12:30 PM
Posted on January 16, 2010 12:30
That is very good news
Posted by voicechat | January 28, 2010 6:59 AM
Posted on January 28, 2010 06:59
For some who doesn't have a twitter,this does not make any relevance.
Posted by Anonymous | February 3, 2010 4:22 AM
Posted on February 3, 2010 04:22