0

Is there a way to make twitter generate a shortened version of my url when using a custom button (according to: https://dev.twitter.com/docs/tweet-button#build-your-own).

I don't need any counters, I just want to share a text, shortened url and a hashtag.

var twUrl = 'http://twitter.com/share?count=none&text=' + encodeURIComponent(text) + '&url=' + url + '&hashtags=' + encodeURIComponent(hashtags);
    window.open(twUrl, 'sharer', 'toolbar=0,status=0,width=650,height=254');

Thanks!

Charles
  • 50,943
  • 13
  • 104
  • 142
Yonder
  • 719
  • 2
  • 13
  • 26

1 Answers1

2

You can use the bitly API to shorten your url's.

Checkout the documentation: http://dev.bitly.com/get_started.html

See also this SO question with a code example in the answer on how to make use of the bitly API using jquery: jQuery on the fly URL shortener

Community
  • 1
  • 1
ThdK
  • 9,916
  • 23
  • 74
  • 101
  • So I will need to use the service manually first, and use the response in my code above? – Yonder Apr 19 '12 at 09:26
  • See my updated answer. It has a link to a SO question that will guide you through the whole process. – ThdK Apr 19 '12 at 09:28