URL shortening broken

mistergoodcat Jan 02, 2012 06:19AM EST

Hi.

I've read through a lot of forum posts and all your documentation on this, but I fail to get url shortening to work. What I use:

* Twitter button ("addthis_button_twitter", NOT the native tweet button)
* A dynamic url (multiple articles on the page) using "addthis:url"
* A twitter template to format the tweet - url embedded using {{url}}
* My own bit.ly account

Url shortening does not work. The sample urls I'm trying are >60 characters, so it's not the issue with the 40 characters limit. I've tried various setups, removed my custom bit.ly account to use the built-in shortening (also not working), passed in the urls using inheritance and directly etc. etc. - it's simply not working, the full url always is sent to Twitter. Code:

<script type="text/javascript">
var addthis_config = {
pubid: "xxxxxxxxxx",
data_track_clickback: false,
url_transforms : {
shorten: {
default: 'bitly'
}
},
shorteners : {
bitly : {
login: 'xxxxxxxxxx',
apiKey: 'xxxxxxxxxx'
}
}
}

var addthis_share = {
templates: { twitter: '{{title}} - {{url}} by @xxxxxxxxxx' }
}
</script>

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>


... somewhere else on the page ...

<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_twitter" addthis:url="<%=[some code that generates the url] %>" addthis:title="<%=[some code for the title] %>"></a>
<!-- ... -->


What is wrong here? Thank you for your help.

4 Community Answers

mistergoodcat Jan 02, 2012 06:43AM EST

Nevermind. The problem was: I was testing all this on my development machine, and hence all the links were either "http://localhost/..." or "http://machinename/...". Apparently the parsing and shortening is not working for that kind of urls. When I uploaded the code to a public domain it worked.

Maybe you can add that as a hint for other to your documentation.

View in conversation


Up 0 Rated Down
mistergoodcat Best Answer Jan 02, 2012 06:43AM EST
Nevermind. The problem was: I was testing all this on my development machine, and hence all the links were either "http://localhost/..." or "http://machinename/...". Apparently the parsing and shortening is not working for that kind of urls. When I uploaded the code to a public domain it worked.

Maybe you can add that as a hint for other to your documentation.
Up 0 Rated Down
kwint.slager Jan 06, 2012 03:46AM EST
@mistergoodcat, can you also tell me that is the reason why i don't have statistics yet? I have the addthis icons in my website, and they work fine, but i don't receive data when i open the analytics tab, is this because i am using them addthis icons from my localhost ??
Up 2 Rated Down
workinginnz Jan 11, 2012 05:03PM EST
Something else that caught me out the first time that may help:

URL Transforms should be added to *** addthis_share *** not addthis_config!

See here: http://www.addthis.com/help/client-api#url-transforms

Here's the code I'm using...

var addthis_share = {
url_transforms: { clean: true, shorten: { twitter: "bitly" } },
shorteners: { bitly : { login: "username", apiKey: "R_3daxxxx..." } }
};
Up 0 Rated Down
seitanist Feb 14, 2012 04:03PM EST
Hey guys - good advice. Can anyone suggest where to call this so your api key isn't displayed in your code?

This question is closed to new answers.

Still need help?


General Topics

 

Developers