Skip to content

Instantly share code, notes, and snippets.

@mapix
Created December 25, 2012 15:54
Show Gist options
  • Save mapix/4373815 to your computer and use it in GitHub Desktop.
Save mapix/4373815 to your computer and use it in GitHub Desktop.
python -c 'import googl; print googl.Googl("<your_google_api_key>").shorten("'$someurl'")[u"id"]'
Google URL shortener
(1) required: python-googl ( install by: pip install python-googl )
(2) get from google API console https://code.google.com/apis/console/
curl -s -d'&url=URL' http://goo.gl/api/url | sed -e 's/{"short_url":"//' -e 's/","added_to_history":false}/\n/'
googl () { curl -s -d "url=${1}" http://goo.gl/api/url | sed -n "s/.*:\"\([^\"]*\).*/\1\n/p" ;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment