When I type into any browser's address bar : https://username:password@www.example.com/Protected/Export/MyFile.zip, the file gets downloaded normally.
Now I'm trying to do the same with PHP : connect to the remote password-protected file and download it into a local directory (like ./downloads/).
I've tried several ways with PHP (ssh2_connect(), copy(), fopen(), ...) but none were successful.
$originalConnectionTimeout = ini_get('default_socket_timeout');
ini_set('default_socket_timeout', 3); // reduces waiting time
$connection = ssh2_connect("www.example.com");
// use $connection to download the file
ini_set('default_socket_timeout', $originalConnectionTimeout);
if($connection !== false) ssh2_disconnect($connection);
Output : "Warning: ssh2_connect(): Unable to connect to www.example.com on port 22 [..]"
How can I download this file with PHP and store it on a local directory ?