Posts

Showing posts from February, 2021

curl - my favourite curl uses, cheatsheet and cookbook

Curl is Like the Swiss Army Knife of Web Tools Curl can be used to test your interactive web applications that use POST, GET, and PUT. Here are some of my all time favourite curl tricks 1) Upload A File to a PHP script curl -F "file=@/var/tmp/log.out;filename=$aname" http://somewebsite.com/uploadfile.php send the file contents and the filename over to your php script 2) Send JSON to a PHP script curl -X POST -H "Content-Type: application/json" http://somewebsite.com/form.php -d '{"username":"Marcus Wong","hostname":"APPLE"}' 3) Login to a Website curl -X POST -H "Content-Type: application/json" http://somewebsite.com/login.php -d '{"action":"login","Email":"johnson@yahoo.com","Password":"4shits","ReturnUrl":"/"}' 4) Use curl in php /* from https://stackoverflow.com/questions/5971398/php-get-contents-of-a-url-or-page */ fun