Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to get some value form outside website which need username and password.
normally I need go to login page first(https://xxx.xxx.xxx/HomeAccess), then go to https://xxx.xxx.xxx/xxx.aspx. But if without login just go to the page xxx.aspx, I will get errror "The page cannot be displayed because an internal server error has occurred.";

in PHP I'm trying use this code
<?php

$ch = curl_init();
$url = 'https://xxx.xxx.xxx/xxx.aspx';
$username ='uuuuu';
$password ='ppppp';
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);

print $output;

?>


I got blank page.

Any idea? thanks
Posted
Updated 22-Jan-18 5:20am

1 solution

you can download page content using below command

curl.exe -u "${user}:${pass}" -L "$page" | Set-Content -Encoding UTF8 $raw
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900