Example of using PHP curl to login, get data via API and download file.
Download file via PHP_CURL with login and using API