0

https://test.e-mac.com/PublishingImages/News/ibtikar%20app.png

this image is password protected and you need to enter username and password to access this. But how can i get it through curl . I used the below php code and get 401 error. In web browser it opens with same username and password

$url = 'https://test.e-mac.com/PublishingImages/News/ibtikar%20app.png';

$username = 'example_user_name';
$password = '********';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

var_dump($output);
dev21
  • 520
  • 2
  • 8
  • 22

0 Answers0