php-curl对远程服务器的授权不起作用

php-curl对远程服务器的授权不起作用,php,post,curl,http-post,Php,Post,Curl,Http Post,请帮忙,我花了三天时间来解决这个问题。 我尝试获得授权并在页面后面显示,如/index.php?page=xml,但我只获得登录页面,一些cookie保存到本地服务器 以下是PHP curl代码: <?php $login = 'XX'; $password = 'XX'; $site = 'http://site'; $cookies = dirname(__FILE__) . '/cookies.txt'; $automatic = curl_init(); curl_

请帮忙,我花了三天时间来解决这个问题。 我尝试获得授权并在页面后面显示,如/index.php?page=xml,但我只获得登录页面,一些cookie保存到本地服务器

以下是PHP curl代码:

    <?php

$login = 'XX';
$password = 'XX';
$site = 'http://site';

$cookies = dirname(__FILE__) . '/cookies.txt';

$automatic = curl_init();

curl_setopt($automatic, CURLOPT_USERAGENT, $user_agent);
curl_setopt($automatic, CURLOPT_REFERER, "http://google.com/");
curl_setopt($automatic, CURLOPT_TIMEOUT, 10);

curl_setopt($automatic, CURLOPT_URL, $site . '/index.php?page=index');


curl_setopt($automatic, CURLOPT_RETURNTRANSFER, true);
curl_setopt($automatic, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($automatic, CURLOPT_POST, true);
curl_setopt($automatic, CURLOPT_POSTFIELDS, "user.auth.login=$login&user.auth.pass=$password");

curl_setopt($automatic, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($automatic, CURLOPT_COOKIEJAR, $cookies);

curl_exec($automatic);

curl_setopt($automatic, CURLOPT_URL, $site. '/index.php?page=xml');
$demo = curl_exec($automatic);

curl_close($automatic);

echo $demo;
?>
网站形式:

<form name=enterform action="/index.php?page=index" method=post>
    <table border=0 cellspacing=0 cellpadding=2 width=740>
        <tr>

            <td valign=bottom bgcolor=#01568D width=80>
                <input type=input maxlength=32 size=9 class="logindata" name="user.auth.login" value="" onKeyDown="return TrapKeyDown(event);" onKeyPress="return TrapKeyPress(event);"><br>
                <input type=password maxlength=32 size=9 class="logindata" name="user.auth.pass" onKeyDown="return TrapKeyDown(event);" onKeyPress="return TrapKeyPress(event);">
            </td>
        </tr>
        <tr>
            <td bgcolor=#01568D height=40 colspan=2 align=right valign=bottom><a href="javascript:document.forms['enterform'].submit();"><font class="startbuttons">LOGIN</font></a>&nbsp;</td>
</tr>
    </table>
    </form>

我做错了什么?

Cookie中的会话号可以从登录改为登录。您能解释更多吗?我认为会话号是每个用户登录时创建的,在调用curl脚本时可能已经过期,因此它将无效。现在我无法理解,但不知道如何通过代码修复它:您确定预期的$u POST键带有点吗?如果是这样,它们将转换为下划线:user.auth.login在接收端变为user\u auth\u login。看来没办法了:
<form name=enterform action="/index.php?page=index" method=post>
    <table border=0 cellspacing=0 cellpadding=2 width=740>
        <tr>

            <td valign=bottom bgcolor=#01568D width=80>
                <input type=input maxlength=32 size=9 class="logindata" name="user.auth.login" value="" onKeyDown="return TrapKeyDown(event);" onKeyPress="return TrapKeyPress(event);"><br>
                <input type=password maxlength=32 size=9 class="logindata" name="user.auth.pass" onKeyDown="return TrapKeyDown(event);" onKeyPress="return TrapKeyPress(event);">
            </td>
        </tr>
        <tr>
            <td bgcolor=#01568D height=40 colspan=2 align=right valign=bottom><a href="javascript:document.forms['enterform'].submit();"><font class="startbuttons">LOGIN</font></a>&nbsp;</td>
</tr>
    </table>
    </form>