Creating a "Tweet This" Link
Posted by Greg Bulmash in Online Marketing And SEO, Web ProgrammingBeen working on a new project that will go into previews for selected friends and family later this week and go into general release a few days later, once I've had a chance to fix any issues my preview users find.
One part of the project was to add "Tweet This" links to certain items on the site, where clicking on the link would send the user to Twitter and fill in the suggested text of the tweet for them.
It's actually a lot simpler than you think. The format is: http://twitter.com/?status=[URL encoded tweet text].
Now many of you are asking how you "URL encode" the tweet text. Well, if you're using PHP, you use urlencode('text'); where "text" is the text of your tweet. If you want to do it in JavaScript, the PHP.js library has a javascript equivalent for PHP's urlencode.
But here's a little trick I didn't know about until I made this mistake. Make sure your link goes to twitter.com, not www.twitter.com. If it goes to www.twitter.com, the text doesn't get properly decoded. So, trying to tweet Creating a "Tweet This" Link - http://www.brainhandles.com would look like Creating a %22Tweet This%22 link - http%3A%2F%2Fwww.brainhandles.com, and nobody wants that.



Entries (RSS)