Post #2 in regards to @AlfredApp and it’s quick because I didn’t write it, I just fixed it. I use Bit.ly links for a lot of things and there was one that I found through Google-Fu but when I tried it, it didn’t work. You can find his work by clicking here: kopischke. This was a long time ago so I was just starting to learn about a lot of the things I’m STILL just starting to learn about, but at a much better rate than before.
Either way, tinkering and tooling got it back (seriously, just a URL change? I remember this taking wayyyyy longer) Code below and extension below or just follow the fork on his GitHub. You’ll need to get your API key from the bit.ly guys but that should be about it. Questions? Throw’em in the comments:
# modified API url to align with changes to bit.ly requirements - @claylevering
# find the .alfredextension here: http://cl.ly/EEUK
declare -r API='https://api-ssl.bitly.com/v3/shorten'
declare -r LOGIN='yourlogin'
declare -r API_KEY='yourapi'
# add http scheme to URL if none is provided
longURL=$(printf "{query}" | sed -E -e 's|^.|http://&|' -e 's|^http://([a-zA-Z\-\.\+]+://)|\1|')
# shorten URL
shortURL=$(curl -sf -d "login=$LOGIN&apiKey=$API_KEY" --data-urlencode "longURL=$longURL" -d "format=txt" $API)
declare -i curlExit=$?
if [ -n "$shortURL" ]; then
printf $shortURL | pbcopy
echo "Bit.ly Generated!"
echo $shortURL
exit 0
elif [ $curlExit -eq 22 ]; then
errMsg="URL '$shortURL' could not be shortened because of a bit.ly server error. Your URL, login or API key may be invalid, or bit.ly may be experiencing technical difficulties."
else
errMsg="URL '$longURL' could not be shortened because of a technical error. The 'curl' command returned with exit code $curlExit. Check the man page for curl for details."
fi # [ -n "$shortURL" ]
And the extension is here: Bit.ly Shortlink.alfredextension