How to automate http authentication url from php

How to automate http authentication url from php

if you have to download a file from a web address that would trigger a username and password window (http authentication), then here is the trick

$downloaded_content = file_get_contents("http[s]://yourusername:yourpassword@thefiledownloadurl");
file_put_contents('/tmp/tempholder.csv', $downloaded_content);

The line of interest would be the first one with file_get_contents.
Once you get the content, you can perform a lot of things, either use the content as it is, or copy it to file using file object or just simply transfer the content to other file as the example depicts..

$_POST vs $HTTP_RAW_POST_DATA vs php://input and enctype

how to deploy symfony application to the production server

Deploying Symfony on Production Server

Run single phpunit test

composer install-update killed on vagrant machine

Check if curl is loaded as module in php

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*