curl-library
Re: Logging into a site
Date: Wed, 14 Dec 2005 17:50:14 -0500
>> I am tyring to log into my account at www.mydomain.com and update an IP
>> address on a page.
>>
>> When I use a PHP script, it returns a blank page or the value 1 --
>> however,
>> I can log into the site from a DOS command window (running NT4).
>
> Well, they probably don't send the exact same requests. For example I
> belive
> the PHP/CURL interface doesn't set the user-agent field.
Yep -- I figured SOMETHING was different -- but as a new user I need help in
figuring out how to figure out the difference(s).
> Let me also point out that there's a separate mailing list for PHP/CURL,
> called curl-and-php.
Yep -- but as I could log in to the site from a command window, I posted in
this group to get started (if I posted to the other group too, someone would
have complained about double posting!)
>> I've read the docs, FAQS, and about login issues (i.e., referer, user
>> agent,
>> certification, etc., etc.). But can't seem to figure out where or what to
>> look for. (I guess I'm stumped partly because I can login from a DOS
>> command
>> window.)
>
> You need to figure out the differences and make the non-working request
> more
> similar to the working one. I believe the --trace and CURLOPT_VERBOSE
> options
> will help you with that.
Well... setting CURLOPT_VERBOSE does not provide me any additional
information at all. The result of these commands:
// --------------------------------------------------------
$my_UserID = "xxx";
$my_PassWord = "yyy";
$c = curl_init(https://secure.registerapi.com/account/login.php); // have
tried other URLs
curl_setopt($c, CURLOPT_COOKIEFILE, "c:\cookie");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS,
"login=$my_UserID&pass=$my_PassWord&redir=https://secure.registerapi.com/account/index.php&noregister=&submit=Log
in");
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); // using this right now as
command window require -k
curl_setopt($c, CURLOPT_VERBOSE, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$Domain_Page = curl_exec($c);
curl_close($c);
// --------------------------------------------------------
is an empty $Domain_Page.
When I add:
// --------------------------------------------------------
$p = curl_error($c);
echo("--------------------------------------------------------- <br>");
echo("curl_error: $p <br>");
echo("--------------------------------------------------------- <br>");
// --------------------------------------------------------
before the "$Domain_Page..." line, I get "<URL> malformed". Did some
research on google about this, but haven't found anything definite so far on
discovering just what the problem is.
>> I can't actually update this page from the DOS command window because the
>> POST values are almost 2.5KB (far longer than a command line can be).
>
> curl can send POSTs read from a file or stdin, so this should be possible
> anyway.
Cool -- as a new cURL user I was not aware of this -- but will give it a try
just to learn.
Received on 2005-12-14