Nov, 5
2009

Using Bit.ly, prettySociable, and jQuery to share shortened links

So I went ahead and made some script modifications to the already awesome PrettySociable jQuery plugin.  These modifications allow for the use of your bit.ly account api to shorten urls.

By default, the prettySociable plugin takes the url supplied and submits that to the share service (twitter, facebook, etc.).  I just made a simple change to allow for the developers to include a bit.ly api and username when calling $.prettySociable() by passing those in as parameters.


$.prettySociable({bitly_api: 'api here', bitly_user:'your username'});


If these options aren’t set, the plugin will use the default url.  If they are, the plugin will automatically call the bit.ly api to shorten the url and use that shortened url instead.

I probably need to test a bit more, but here is the jquery.prettysociable.bitly.js script and here it is minified: jquery.prettysociable.bitly.min.js.

Links that helped me with this:
Bit.ly
PrettySociable plugin page
jQuery HowTo @blogspot

Leave a Reply