Created
December 27, 2012 00:28
-
-
Save carlosmcevilly/4384342 to your computer and use it in GitHub Desktop.
expand a bit.ly URL to its original URL. Need a bit.ly developer account to use this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# change these to your own | |
export userid=<user_id_string_from_bitly_account> | |
export key=<key string_from_bitly_account> | |
export link=$1 | |
if [[ "$link" == '' ]] | |
then | |
echo usage: $0 '<link>' | |
exit -1 | |
fi | |
export expand="http://api.bit.ly/v3/expand?shortUrl=$link&login=$userid&apiKey=$key&format=txt" | |
wget -q --output-document=temp.txt.$$ $expand | |
cat temp.txt.$$ | |
/bin/rm temp.txt.$$ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's another way, from user atoponce at commandlinefu.com, using a service of longurl.org:
expandurl() { curl -s "http://api.longurl.org/v2/expand?url=${1}&format=php" | awk -F '"' '{print $4}' }