Julienh / Sharrre

Make your sharing widget! Sharrre is a jQuery plugin that allows you to create nice widgets sharing for Facebook, Twitter, Google Plus (with PHP script) and more.
sharrre.com
MIT License
1.04k stars 411 forks source link

Difference between tiny url and real url #84

Open fdavid opened 11 years ago

fdavid commented 11 years ago

Hi,

I am using a shortener to share url of my website (like bit.ly). When displaying the counter, it always show 0 even if there is more than 0 share (I tried for FB and TW). It is because TW and FB register the real url for counting and not the tiny url.

Example for twitter : http://cdn.api.twitter.com/1/urls/count.json?url=http%3A%2F%2Fwww.liste-noire.org%2Fcompagnies-aeriennes%2FU2%2Feasyjet%2Favis%2F4250%2Fvol-de-nice-a-lille-par-bruno-mic%2F&callback=jQuery17208600041456774824_1350211961843

return 1 for sharing

While the tiny url of this url return 0 http://cdn.api.twitter.com/1/urls/count.json?url=http://wtf.tl/a/1/1/a/16y/

Edit : It seems like G+ is using the shorten one for counting...

Could you make the difference between those two ?

Thanks for your time!

thomask commented 10 years ago

Did you find a solution? I have the same problem..

thomask commented 10 years ago

ping @fdavid

decadeofdefeat commented 9 years ago

I modified the sharrre js file to make short URLs work for Twitter.

In the HTML code add a data-shorturl value and add the bitly link

 data-url="http://www.yourdomain.com/full-long-link/"  data-shorturl="http://bit.ly/12345"

Add the shorturl to the defaults array and set it to the same as the url

 shorturl: document.location.href,

In Plugin.prototype.init, check it shorturl exists:

 Plugin.prototype.init = function () {
 ...
 if(typeof $(this.element).data('shorturl') !== 'undefined'){
  this.options.shorturl = $(this.element).data('shorturl');
}

In popup array, add the shorturl to the Twitter URL string if it exists

 twitter: function(opt){
  window.open("https://twitter.com/intent/tweet?text="+encodeURIComponent(opt.text)+"&url="+encodeURIComponent((opt.shorturl !== '' ? opt.shorturl : opt.url))+(opt.buttons.twitter.via !== '' ? '&via='+opt.buttons.twitter.via : ''), "", "toolbar=0, status=0, width=650, height=360");
},