Twitter Share Link Creator

A share link creator is an ubiquitous tool, especially for those working in digital marketing.
There are a couple of websites that have scripts that help generate these links. A google search will throw a bunch of websites that help you generate such links and the one I like the most is http://mashe.hawksey.info/sharegen.php (largely for its simplicity). However, there is a problem with these websites.
They don’t generate the perfect tweet you want, one that includes the text, a hashtag and an URL. Most these services don’t generate a tweet link with a hashtag and the ones that support hashtags don’t append the URL.
So, I decided dig this a bit more to figure out the best way to generate the twitter share links, that can support hashtags and URLs as well.
The solution I found was very simple. The best way is to construct the URL yourself.
Below is the structure

https://twitter.com/intent/tweet?
url=
text=
hashtags=

A sample tweet would be

https://twitter.com/intent/tweet?
url=www.surendran.info/twittershare
text=How to generate a twitter share url with
hashtags=hashtag,twitter,social media

The final URL will look like
https://twitter.com/intent/tweet?url=http://www.surendran.info/twittershare&text=How to generate a twitter share url with hashtags?&hashtags=twitter,socialmedia,hashtags
To make tracking easier, you can use bitly. The short link of the above long url would be something like http://j.mp/19SajuU
However, this method isn’t 100% perfect either. Some challenges I identified in this include

  • You cannot alter the structure of the tweet. It remains text, url, hashtags
  • You cannot insert hashtags in the text
  • If you add special characters in the text it doesn’t work. Just ‘?’ works.
  • You have to stick to the syntax. Things like spaces, a extra ‘/’ at the end of the URL etc will result in a wrong URL or a truncated tweet.

Lemme know if this works and if you have more ideas to generate better share links for twitter.
PS: The share URL makes use of the Twitter web intent. In addition to the URL and hashtags, it supports a couple of other parameters too. Read more here