Twitter Status URL’s and Ampersands « Km0 Blog

Twitter Status URL’s and Ampersands
- by Alexandru Petrescu

Recently I’ve had to do a bit of integration with Twitter on a site I was working on.  In order to allow people to easily post links to Twitter, I created specially formed URL’s to pass a message and link to Twitter.

Making the URL is simple, it looks something like this:

However, if you add an Ampersand (&) to the message it breaks the URL, like so:

You can escape the ampersand using %26, however it shows up as %26 in the actual message, like so:

It seems that Twitter doesn’t want to use as their main domain.  They want to use, so they redirect.  When they redirect, it does encodes the previous url and passes it to the domain.  So %26 turns into %2526 (%25 = %).

However, if you form your url to go directly to it won’t do the redirect and it’ll work just fine.  So the final good url is:

Last tip, if you use this method of posting to Twitter, make sure you send the user to and not to  The URL works if you’re already logged in (which you might be if you’re developing the application), but if you have to login first, it won’t forward the message.  Going to the /home page will allow you login and then forward the message.

Also, when making the url’s make sure you use +’s and not %20’s.


Leave a comment

You must be connected to post a comment.