Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # -----------------------------------------------------------------------------
- # author: Santhosh veer
- # file: short
- # Last Change: ago 21 2019 14:26
- # -----------------------------------------------------------------------------
- # Requirements: curl, jq, xclip
- # Description: Simple Shell script to Shorten your Long URL via Bitly API V3.
- # -----------------------------------------------------------------------------
- # Reference: https://unix.stackexchange.com/questions/69111/
- # Source: https://itrendbuzz.com/bitly-url-shortener-using-shell-script/
- # Get Bitly Generic access token
- # Log in to your Bitly account
- # Open this Link- https://bitly.com/a/oauth_apps & get your Generic access token
- # Bitly Generic access token & Username
- # In my case I have protected my token in a file that I have permissions to read
- Accesstoken=$(cat ~/.config/bitly-token)
- username="voyeg3r"
- # echo -n "Enter your Long URL: "
- # read -r longurl
- # echo "[+] URL Shortening Started..."
- # If no URL you will see this Alert message
- if [[ ! ${1} ]]; then
- echo -e "Error URL Missing"
- exit 1
- fi
- # Curl request
- # curl -s --request GET \
- # --url "https://api-ssl.bitly.com/v3/shorten?access_token=$Accesstoken&login=$username&longUrl=${1}" \ | jq
- # Curl request
- curl -s --request GET \
- --url "https://api-ssl.bitly.com/v3/shorten?access_token=$Accesstoken&login=$username&longUrl=${1}" \ | jq \ |
- awk -F'"' '/"url":/ {print $4}' | tee >(xclip -i -selection clipboard)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement