Is the script being run on the same server as the protected directory? If so, the username/password shouldn't even be an issue - just access the file locally via the file system rather than through the web server.
If not, one way you could retrieve the remote data using standard HTTP authentication is by using [man]cURL[/man]. For example, see the manual page for [man]curl_setopt/man and note the CURLOPT_USERPWD option.