CURL

From Indie IT Wiki

A command line tool for transferring data with URLs.

https://curl.haxx.se

Using Variables

You have to use double double quotes and escape the ones you need!

If you want to end up with an IP address in quotes...

"123.456.78.90"

... it has to be written as

"\""${MYIP}"\""

...so that the shell can expand the variable.

For example, calling the GANDI Live DNS API to update a record for fish.mydomain.com using your public IP address...

export MYIP=$( curl -s ifconfig.me ) && curl -s -X PUT -H "Content-Type: application/json" -d '{"rrset_values":['"\""${MYIP}"\""']}' -H "Authorization: Apikey xxxxxxxxxxxxxxxxxxxxxxxx" https://api.gandi.net/v5/livedns/domains/mydomain.com/records/fish/A

SNI

Server Name Identification is the method of requesting a partuclar host on a shared server, to make sure you request the correct SSL Certificate.

The curl option 'resolve' allows you to specify which IP address to resolve the domain name to, great for testing an Let's Encrypt SSL Certificate...

curl -vik --resolve domain.org.uk:443:172.17.0.2 https://domain.org.uk

POST

curl -X POST -F 'ip=23.129.64.235' https://www.zerospam.org/wp-json/v1/query

Output To File

curl -O URL

Follow Redirection With Details

curl --insecure --verbose --location URL

Manual

https://curl.haxx.se/docs/manual.html