I have a page which uses a the hash # to store some extra bit of info.
I want to add a button [short url]
which via javascript should
- get the current url (easy location.href)
- pass it to some url shortener service (eg. bit.ly) etc.
- get back the new url and show it in a textfield for the user to copy and paste (easy again)
It’s point 2 that I don’t know how to do (or if it is doable at all)
Note: that all of this should be solved on the client side nothing on my server side.
From http://code.google.com/p/bitly-api/wiki/ApiDocumentation#API_Key_Security
API Key Security
To ensure the absolute security of your API key, we suggest that you always make API calls server-side.
If it is absolutely necessary to call our API from client-side code, please keep in mind that there is no way to positively ensure that your API key will not be discovered. However, certain measures can be taken to mitigate this risk.