Hi all
so I'm new to scripting but I am making a script that is a url shortener. It will take a url off the command line and spit back the shortened version using bit.ly's api
this is what I have so far
if [ $# -lt 1 ]
then
echo "You must supply a URL."
exit 1
fi
read url
curl "https://api-ssl.bitly.com/v3/shorten?access_token=xxxxxxxxxxxxxxxxxxxxxx&longUrl=$url"
curl -d
I am not entirely sure if I am using this correctly. I know curl will fetch the direct URL for the conversion but I dont know if it is legal to stuff '$url' directly into the http address. Curl -d will post the data but I'm a bit confused as to what URL I'm supposed to use there. . .
basically what i want to do is fetch the url off the command line and stuff it into that http address after '&longURL=' where the url is supposed to be. Then I need to fetch back the shortened version of the address.
this is the api
ApiDocumentation - bitly-api - bitly REST API method documentation - API Libraries and Documentation for bitly - Google Project Hosting
and this is the page ive been reading regarding curl
cURL - Tutorial
I believe curl -d will post data granted I provide the information after it to post it but I dont know what should go after curl -d. .I am new to using APIs and im just picking this up
any help is appreciated thank you