I have a webpage with a list of HTML links for images in a protected subfolder. This folder is protected via .htaccess and HTTP authentication.
Is there a way to use cURL/Socket, or something like that, to access to the subfolder?
If you are talking about HTTP Basic authentication, then you can provide the necessary credentials with
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); // enable HTTP Basic auth
curl_setopt($curl, CURLOPT_USERPWD, "username:password"); // credentials
There are also some other options that may be of interest such as CURLOPT_PROXYUSERPWD (if you are going through a proxy) and CURLOPT_UNRESTRICTED_AUTH (if the initial host redirects you to another domain where the actual authentication takes place).
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(CURLOPT_USERPWD, '[username]:[password]')
$data = curl_exec();
curl_close($ch);
?>