PHP/Curl and 401 errors
| From: | James Taylor | Date: | Fri, 25 Apr 2003 03:30:31 +0000 |
| Subject: | PHP/Curl and 401 errors | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-145218@lists.php.net to get a copy of this message | ||
I'm trying to logon to a site through https, punch in the user name and
password, sent my post data and then retrieve the results of the site.
Whenever I do this however, I'm getting back the error:
HTTP 401.2 - Unauthorized: Logon failed due to server configuration
Internet Information Services
---
Technical Information (for support personnel)
Background:
This is usually caused by a server-side script not sending the proper
WWW-Authenticate header field. Using Active Server Pages scripting this
is done by using the AddHeader method of the Response object to request
that the client use a certain authentication method to access the
resource.
More information:
Microsoft Support
The page I'm posting to is in ASP, and the server is obviously a windows
machine.
Is there some sort of special header I need to pass on with CURL to get
something like this to work? This is what the curl portion of the
script looks like:
$post="&date=4/27/01&type=FILE"
$f=curl_init();
curl_setopt($f,CURLOPT_URL,'https://www.somesite.asp/post.asp');
curl_setopt($f,CURLOPT_USERPWD,"myusername:mypassword");
curl_setopt($f,CURLOPT_POSTFIELDS,$post);
curl_setopt($f,CURLOPT_POST,1);
curl_setopt($f,CURLOPT_RETURNTRANSFER,1);
$info=curl_exec($f);
curl_close($f);
I don't know a whole lot about curl, so any help with this would be
GREATLY appreciated. Thanks