I have a problem with HTTP authentication. I could not get the contents of this url because it needs http authentication.
the code:
<?php
$url = "http://www.abcdefg.com/12345/";
$username = 'username';
$password = 'password';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$out = curl_exec($ch);
print "error:" . curl_error($ch) . "<br />";
print "output:" . $out . "<br /><br />";
curl_close($ch);
?>
The problem is this: Instead of showing real content, it shows "302 Found, document has moved here."
I tried "http: // username: password@www.abcdefg.com/12345/", it doesn’t work.
When accessing this URL (1), a pop-up window asks for a username and password. but the popup is from another url (2) (sso authentication server). if authenticated. then it returns to the url (1) again. at this time, I can access the contents of this URL (1).
firebug , URL- :
1
URL: GET http://www.abcdefg.com/12345/
Status: 302 Found
Protocol: http
2
URL: GET https://www.ssoauth.com/obrareq.cgi?wh=xxx wu=xxx wo=xxx rh=http://www.abcdefg.com ru=/12345/
Status: 302 Redirect
Protocol: https
3
URL: GET http://www.abcdefg.com/obrar.cgi?cookie=xxxxxxxxxxxxxxx
Status: 302 Found
Protocol: http
4
URL: GET http://www.abcdefg.com/12345/
Status: 200 OK
Protocol: http
...
- cookie?
php curl ?