Update: v1.3 available here
Seeing as I’ve put a Twitter feed on the side of the website, I thought I may as well start using Twitter more often! Why not have an extension that automatically updates my Twitter status whenever a new post is made on CreepinJesus.net?
Why not, indeed. So, here we have it. Currently at version 1.1 (after some testing), the extension is easily installed and works with only a little tweaking.
Requirements
- A Twitter account (obviously)
- The Twitterizer API (included in the download)
Installation and Setup Instructions
- Un-zip the files to …wherever you like!
- Open up the Twitterizer folder and copy both files to the bin folder of your website.
- Copy TwitterUpdater.cs to the App_Code/Extensions folder of your website.
- Sign in to your site and go to the Extensions page. This may take a while to load on the first visit.
- Click on Edit under the Settings column for TwitterUpdater.
- Enter your Twitter username and password.
- Also enter the text you would like to see in your Twitter status update. For example, New post on MySite.com - {0}. The "{0}" is very important - this is where the TinyURL link to your post will be placed in the status text. It can be anywhere in the status text, though, so as another example: Visit {0} for a new post! Just remember that Twitter has a maximum of 140 characters, so to make sure it all fits try to keep your message below 100 characters.
- Click Save to save your settings.
- All done :) Now whenever you publish a new post, your Twitter status will be updated.
Issues/Problems
The only issue so far is the way the extension knows whether it has updated Twitter for a given post or not. At the moment, is is using the following code:
_post = (Post)sender;
if (_post.IsVisibleToPublic)
{
TimeSpan ts = DateTime.Now.Subtract(_post.DateCreated);
if (ts.TotalSeconds <= 10)
{
// Update Twitter
}
}
What this is doing is checking to see whether the post is visible to the public first (no point linking people to a hidden post!), then if it was created in the last 10 seconds it is considered a new post.
This means that if you have created a post and saved it without publishing it, it will not be announced on Twitter when you change the post’s published state to Published (unless you do it within 10 seconds of first creating the post).
This is something I will be working on in the future. I will try to use methods that are available in the standard release of BE so it will work for everyone without having to modify source code. In the mean time, just remember that limitation.
Once again, here is the download link: http://dl.dropbox.com/u/4162408/blogengineExtensions/TwitterUpdater.zip.
If you have any problems or feedback, please add a comment below! If you'd like to donate even a small amount to me to help fund my projects and education, please click the Donate button on the right. Thank you :)
Last modified: 1 July 2010, 9:09 by CreepinJesus
d9dcf589-63b8-405e-8113-ae260c37aa7b|1|5.0
Downloads
twitter, download, extension, blogengine, twitterizer, donate